There is a difference between the energy of their ground electronic state, where no electrons have been excited by an incoming photon, and their excited electronic state, where at least one electron has been moved to a higher orbital than it normally occupies. The difference between these 2 states determines how much energy they absorb when they get excited and emit when they relax (go back to their ground state). Energy of light absorbed or emitted =Planck's constant*frequency of light absorbed or emitted. Frequency of light = speed/wavelength.