On this page
Next time the shopkeeper beeps a packet of biscuits, watch the red line on the stripes. That beep is a physics lesson on reflection and absorption of light, followed by a small maths puzzle you can check on any packet at home.
How does a barcode scanner read the black lines?
The scanner shines light across the bars and measures how much comes back.
In a black-and-white barcode, the black lines absorb more light and reflect less than the white lines, as this explainer from barcode-software maker Scanbot puts it. A light sensor, either a photodiode or a CCD (a strip of tiny light sensors), captures the reflected light and turns the changing brightness into an electrical signal, which the scanner's software then decodes into digits.
So the stripes become a wave: high over a white gap, low over a black bar. The scanner only needs to time how long the signal stays high or low, because that tells it how wide each bar and gap is.
Why does light come back at all if the scanner is held at an angle? Paper is rough at a tiny scale, so it scatters light in all directions (diffuse reflection), and some always heads back to the sensor. Black ink absorbs most of the light, so little returns.
Why are some bars thick and some thin?
The widths are the code. On the 13-digit EAN-13 barcodes used on retail products, the barcode consists of 95 areas, called modules, of equal width, each either black or white, according to the International Article Number entry on Wikipedia.
That same source sets out the layout:
3 modules at the start (bar, gap, bar), a guard pattern that tells the scanner where the code begins
42 modules for the left half, seven per digit
5 modules in the middle (the centre guard)
42 modules for the right half, seven per digit
3 modules at the end
Each digit is drawn with two black bars and two white spaces, each 1 to 4 modules wide. The left and right halves use different sets of digit patterns, so the same digit looks different on each side of the centre guard.
Why can't a barcode be printed in red?
This is where the colour of the light matters. GS1 US, the barcode standards body in the United States, says the best colour combination is black bars on a white background, and tells designers to avoid red or reddish bars such as brown because scanning lasers use red light and red bars are "invisible" to it. A red scanning laser's wavelength is usually about 650 nm, according to the Scanbot explainer.
Red ink looks red because it reflects red light. Shine pure red light on it and it reflects strongly, just like white paper, so the bars vanish for the scanner. Dark blue or dark green bars absorb red light, which is why they work.
It is the same absorption that makes white clothes feel cooler in summer and the same selective absorption that explains why the sea looks blue.
How do you check if a barcode number is valid?
The last of the 13 digits is a check digit. GS1, the global standards body, gives the method: multiply each digit by a weight, add the results, then subtract the sum from the nearest equal or higher multiple of ten. For a 13-digit code, the weights for the first 12 digits run 1, 3, 1, 3 and so on.
Worked example, using a made-up number that starts with 890 (in India, GS1 barcodes begin with 890 and only GS1 India is authorised to issue them):
First 12 digits: 8 9 0 1 0 0 2 0 0 3 0 0
Multiply by 1, 3, 1, 3...: 8, 27, 0, 3, 0, 0, 2, 0, 0, 9, 0, 0
Add them: 8 + 27 + 3 + 2 + 9 = 49
Nearest equal or higher multiple of ten is 50, and 50 minus 49 is 1
Full number: 8901002003001
If a single digit is misread, the sum changes and the check digit no longer matches, so the read is rejected. The diagram at the top shows this exact number drawn as bars, with the signal a sensor would produce.
Try it at home: a five-minute experiment
You need a few packets and a phone barcode app.
Pick any packet and do the check-digit sum on paper. Does your answer match the last digit printed?
Scan it, then cover it with shiny clear plastic and scan again. Shiny plastic reflects like a mirror, at one angle.
Slightly wet a printed barcode and try again. Wet paper sends less light back, which is also why wet clothes look darker.
Explain each failed try using the words reflection, absorption and contrast.
For ideas that are easier to see than to read, the Fermi Simulation Lab has interactive simulations.



