We can never visit a star, but we can catch its light. Every element leaves its own barcode of colors in that light. In this lab you'll photograph glowing gases through your own spectroscope, turn the photos into real measurements, identify a mystery gas, and then read the barcodes hidden in starlight.
Units & words cheat sheet
Tip: tap any underlined number on this page to translate it.
nm
nanometer, a billionth of a meter. Visible light runs from about 400 nm (violet) to 700 nm (red). A human hair is about 70,000 nm wide.
spectrum
light spread out by color (wavelength). Plural: spectra.
emission line
a bright line: one exact color given off by a glowing gas.
absorption line
a dark line: one exact color soaked up by a cooler gas in front of a bright light.
calibrate
teach your measurement which pixel on the camera matches which wavelength, using lines you already know.
eV
electron-volt, a tiny unit of energy used for atoms and light.
1
Rainbows and lines
A diffraction grating spreads light out by color. What you see depends on what made the light.
Predict first: you look at a glowing tube of hydrogen gas through your grating. What will you see?
Three kinds of spectra: a hot, glowing solid (like a bulb filament) makes a continuous rainbow. A thin glowing gas makes bright lines. A cool gas in front of a bright light makes dark lines at exactly the same colors. You'll use the bright lines today, and the dark lines when we get to stars.
2
Where the lines come from
Why does a gas give off only a few exact colors?
ModelElectrons in an atom can only sit on certain "steps" (energy levels), like a ladder. When an electron jumps down, the atom shoots out a bit of light (a photon). Bigger jump = more energy = bluer light.
Start on step
Jump down to
Pick a start step and an end step, then make the jump.
Your hydrogen spectrum
Challenge: find all 4 jumps that make visible light. 0 / 4
You built hydrogen's fingerprint!
These are the Balmer lines: Hα (red, 3→2), Hβ (aqua, 4→2), Hγ (5→2) and Hδ (6→2, both violet). They're the same lines you'll photograph in the hydrogen tube, and you'll use them to calibrate your spectroscope in Mission 4. Other elements have different ladders, so they make different patterns.
For the curious: how the math works
Hydrogen's steps have energies E = −13.6 eV ÷ n². The light's energy is the gap between the steps, and its wavelength is:
wavelength (nm) = 1240 ÷ energy gap (eV)
Make a jump to see your numbers.
3
From photo to spectrum
Turn a picture of colored lines into a real measurement.
Take a photo of a glowing tube through your spectroscope, then load it here. The page lines up the rainbow and adds up the brightness at each spot along it. That turns the 2D photo into a 1D spectrum: brightness vs. position on the camera.
What's in your photo? The bright stripe in the middle, inside a glow, is the slit itself: light that went straight through the grating (astronomers call it the "zero order"). The grating bends each color off to the side, so you get a copy of the spectrum on each side, mirror images, with violet closest to the slit and red farthest out. You may also see a faint smear of extra colors and dim "ghost" lines from light bouncing around inside the tube. That's normal; the page knows to look for the sharp lines.
🔒 Your photos never leave your device. All the measuring happens right here in your browser.
📱 Taking a good spectrum photo
Lock the phone to the spectroscope (rubber bands or tape) so the camera looks through the grating at the slit. Don't move it between photos. That's what lets one calibration work for every photo.
Use the normal camera at 1×. Don't zoom. On iPhone Pro models, turn Macro off so the phone doesn't switch lenses.
Darken the room. Tap the screen on the colored lines to focus, then slide the brightness down a little so the bright lines aren't washed out to white.
Turn the phone until the colors spread sideways across the screen, with the bright slit in the middle and a rainbow copy on each side.
Sharper lines: make the slit narrow (two pieces of tape or card edges almost touching), put the slit right up against the glowing tube, and line the inside of the tube with black paper to cut down on ghosts.
Take one photo per tube: hydrogen first, then the others.
Current photo:none yet
Load a photo or try an example above.
The amber box is the measuring box: only light inside it gets measured. Tap the photo to move it up or down, or draw your own box around just the lines you want (for example, one side of the slit).
Your 1D spectrum
Check yourself: why do the lines look straight up-and-down in the photo, but become peaks in the graph?
How the page builds a 1D spectrum
Straighten. The page rotates the photo so the colors run exactly left to right. Auto-straighten tries many small tilts and keeps the one where the lines come out sharpest.
Pick the band. Only the rows inside the amber box are used. That keeps out the dark sky around the lines and any glare.
Add down each column. For every column of pixels, the page adds up the brightness of each pixel in the band. A colored line is bright in every row, so its column adds up to a tall peak.
Find the peaks. A peak counts if it's the brightest spot nearby and stands well above its surroundings. Its exact center is the balance point of the bright pixels, so even a washed-out line gets a precise position.
Load a photo to see your numbers.
4
Calibrate with hydrogen
Teach your spectroscope which pixel is which color, once.
Right now your graph is in pixels. To turn pixels into wavelengths, use lines you already know: hydrogen's Balmer lines from Mission 2. Load your hydrogen photo, tap a peak on one side of the slit, and tell the page which line it is. Two lines are enough: the red Hα (farthest from the slit) and the aqua Hβ. The page measures every line from the slit, so it can also work out what kind of grating you have.
Current photo:none yet
Tap a peak on the graph.
My grating:
Lines used
—
Groove spacing
—
Saved calibration
none
Your calibration is saved. You take a new photo of a different tube, but your friend bumped your phone. What happens?
For the curious: how the calibration works
The grating equation. A grating with grooves d apart bends light of wavelength λ by an angle θ where
sin θ = λ ÷ d (d = 1,000,000 nm ÷ lines per mm)
The camera turns angles into pixels. A line bent by θ lands a distance from the center of the pattern of
distance = F × tan θ where F depends on your phone's lens.
Two known lines pin it down. Each Balmer line you identify gives one (pixel, wavelength) pair. With two, the page solves for F and the exact center. Trying both common gratings, it keeps the one whose center lands on the slit you photographed.
Every later photo uses the same F, measured from wherever the slit lands in that photo. So small shifts of the phone are handled automatically, but tilting or zooming the camera is not.
If the page can't find the slit (for example, it's cropped out), it falls back to a simple straight-line scale between your two lines.
Calibrate to see your numbers.
5
Name that gas
Every element has its own barcode of lines. Match the barcode, name the gas.
The reference fingerprints
Lab wavelengthsLine positions are lab-measured values from the NIST Atomic Spectra Database. Brightness is approximate.
Your measured spectrum
Load a photo of each gas tube here (keep the phone where it was for the hydrogen photo). With your calibration, the graph now reads in nanometers. Turn on reference fingerprints and see which one lines up with your peaks.
Gas photo:none yet· your hydrogen calibration photo stays in Mission 4
Load a photo of a gas tube above.
The same measuring box as your calibration is used. Tap the photo if you need to move it up or down.
Calibrate first in Mission 4 (your hydrogen photo, or the example hydrogen photo).
Overlay:
Your lines
Best matches
Phone measurements are usually good to a few nm, so the matcher allows some wiggle room. A mix of gases can match more than one element.
My answer:
My lab notebook
Save each spectrum you measure to build your own wall of barcodes.
6
Barcodes in starlight
Now point it at the sky. These are real spectra of stars.
A star is a hot glowing ball wrapped in thinner gas. That gas absorbs its own fingerprint colors, so star spectra show dark lines in exactly the places your gas tubes made bright ones. Same barcodes, opposite color.
A. What is the Sun made of?
Real dataSpectrum of a star just like the Sun (type G2). Turn on each element's fingerprint. If its lines land on dark dips, that element is in the star!
The element found in the Sun first
In 1868, astronomers watching a solar eclipse saw a bright yellow line at 587.6 nm that matched no element known on Earth. They named the mystery element after the Greek word for the Sun, helios. Helium wasn't found on Earth until 1895. Check your helium tube's brightest line: it's that same yellow line. Then try the helium fingerprint above: it doesn't show up as dips in ordinary sunlight, which is why it hid for so long.
B. Different stars, different barcodes
Real dataSeven real stars, from the hottest type (O) to the coolest (M). Turn on fingerprints and hunt for the lines.
Why do the barcodes change? Every star contains hydrogen, but a line only shows up if the gas is at the right conditions to absorb it. Hydrogen's visible lines are strongest around 10,000 K (type A). In the hottest stars the hydrogen is too stirred up to absorb these colors; in the coolest stars it's too calm. Cool stars are cool enough for atoms to stick together into molecules like titanium oxide (TiO), which carve wide bands. So a star's barcode tells you what it's made of and what conditions its gas is in.
C. A star that breaks the rules
Real data · SDSSThis is SDSS J215018.83+003547.8, a dwarf carbon star. Normal stars have more oxygen than carbon. This one has more carbon, which forms molecules like C₂ that carve wide, sawtooth bands into the spectrum. Dwarf carbon stars probably got their carbon from a companion star that has since died, which makes them clues to how pairs of stars live and die together.
The wide dips at 474, 517 and 564 nm come from…
★
My detective report
Fills in as you go.
Closing thought
We can't visit a star, but its light carries the barcode of every element in it. The same lines you photographed today are how astronomers know what the universe is made of.