Hydrogen's bright-line spectrum has a few sharp lines, not a rainbow. Photons and the Photoelectric Effect explains why that means its energy is fixed in steps: each line is one photon, and one photon size means one energy jump. Niels Bohr found the energies of hydrogen's levels in 1913.
🔑 Key idea
Hydrogen's electron can have only the energies $$E_n = -\frac{2.18 \times 10^{-18}\ \text{J}}{n^2}, \qquad n = 1, 2, 3, \ldots$$ A jump from level $n_i$ to $n_f$ changes the atom's energy by $\Delta E = E_f - E_i$. Falling ($\Delta E < 0$) emits a photon; rising ($\Delta E > 0$) needs one to be absorbed. Either way the photon's energy is $|\Delta E|$ and its wavelength is $\lambda = hc/|\Delta E|$.
💡 Why it works
Energy zero is the electron just free of the atom. A bound electron has less energy than that, so $E_n$ is negative, and most negative at $n = 1$, the ground state. Because of the $1/n^2$, the levels crowd together as $n$ grows: $E_1 = -21.8$, $E_2 = -5.45$, $E_3 = -2.42$, $E_4 = -1.36 \times 10^{-19}$ J, approaching zero. The drop from 2 to 1 is bigger than all the higher gaps put together, so it gives ultraviolet light, while drops to $n = 2$ give visible light. Energy is conserved: the atom loses exactly what the photon carries away.
Hydrogen's levels drawn to scale. Drops to $n = 2$ (the Balmer series) give the visible lines at 656, 486, 434 and 410 nm.
✏️ Worked example: The red line
Find the wavelength of the photon emitted when hydrogen's electron falls from $n = 3$ to $n = 2$.
Negative: the atom loses energy and emits a photon of $3.03 \times 10^{-19}\ \text{J}$.
$$\lambda = \dfrac{hc}{|\Delta E|} = \dfrac{(6.626 \times 10^{-34})(3.00 \times 10^{8})}{3.03 \times 10^{-19}} = 6.57 \times 10^{-7}\ \text{m} = 657\ \text{nm}$$ red light. (The measured line is 656 nm; the small difference is rounding in the constants.)
Answer: About $657\ \text{nm}$.
✏️ Worked example: Absorbing ultraviolet light
What wavelength must hydrogen absorb to go from $n = 1$ to $n = 4$?
$$\Delta E = -2.18 \times 10^{-18}\left(\dfrac{1}{16} - \dfrac{1}{1}\right) = +2.04 \times 10^{-18}\ \text{J}$$ positive because the atom gains energy.
Two traps. First, picturing the levels as evenly spaced or spreading apart; they crowd together near zero, so high jumps are small. Second, a negative wavelength: $\Delta E$ is negative for emission, but a wavelength is a length. Use $|\Delta E|$, and let the sign tell you whether light was emitted or absorbed. Check: any drop to $n = 1$ is ultraviolet (under 122 nm), and drops to $n = 2$ fall between 365 and 656 nm.
Drops to $n = 1$ form the Lyman series (ultraviolet), drops to $n = 2$ the Balmer series (visible), and drops to $n = 3$ the Paschen series (infrared). Bohr's formula works only for one-electron species; other atoms need the full quantum theory of the next topics.