Mechanism · Information Technology · Software
How barcodes work
Everything a linear barcode says is said with one trick: time. A beam crosses the label, and the decoder measures how long the returning light stays dark and how long it stays bright. The message lives in the widths.
From the book The Barcode: Line, Light, LedgerChapters 9 and 13. Read the full book free as a PDF.
Time, not position
A dark interval one module long is a thin bar; three modules, a thick one; the spaces between bars are read the same way, because the message lives in both. The decoder first finds the edges, converting the smooth analog flicker into timed pulses; then divides the pulses into modules; then looks the patterns up in the symbology's table and reads out characters. Because the encoding is in relative widths, not absolute positions, the same label read fast or slow, near or far, yields the same sequence of ratios. That is why a checkout scanner tolerates a can swept past at any speed or angle.

Guards, quiet zones and halves
The symbol is a small disciplined machine. Guard patterns at the ends give the decoder a known starting rhythm, the way a conductor's upbeat sets the tempo. The mandatory blank margins on either side, the quiet zones, are the silence that tells the scanner the sentence has begun and ended; a surprising share of real-world scan failures trace to something printed in the quiet zone. And because the left and right halves of a UPC use different pattern families, the decoder can read the symbol backwards or forwards and still know which digit is which, a property called bidirectionality. The crossing lines of a slot scanner's fan let it assemble one full read from fragments of several sweeps.
The check digit: the symbol's conscience
The last digit of a UPC is computed, not assigned. Add the digits in the odd positions and multiply by three; add the digits in the even positions; the twelfth digit is whatever brings the total to the next multiple of ten. Every scan recomputes it, so a single misread digit, a bar widened by ink spread or narrowed by a worn press, almost never passes silently; the arithmetic complains. GS1 applies the same alternating-weight rule across its numeric keys. It is error detection, not correction or proof of authenticity: swapping two adjacent digits whose values differ by five leaves the check unchanged, and a perfect copy of a valid number has a perfect check digit. The code checks the transcription of the identifier; it cannot certify the object carrying it.
Why the lines survived the squares
Two-dimensional codes arrived in the 1990s with cameras, error correction and a hundred times the capacity, and the linear code did not die. The reason is the oldest one in the industry: cost and habit. A stripe code prints on any press, scans on any cheap laser, and says the one thing most commerce needs said: look me up. The squares took the jobs that needed more said, more reliably, in less space, and the two families settled into the division of labour the world still lives with: stripes for the checkout, squares for the hard cases.
The vocabulary
The field's vocabulary is small. A symbology is an encoding language, the rules mapping characters to bar patterns: UPC, Code 39 and Code 128 are different symbologies the way French, German and English are different languages over one alphabet of bars. A discrete symbology like Code 39 pads every character with a gap, forgiving sloppy printing at the cost of space; a continuous one like Code 128 packs edge to edge for density. A two-width code knows only wide and narrow; a many-width code like the UPC family measures four widths and packs more per inch.
The license plate
One trick never appears in the symbol at all: the lookup. A barcode in commerce is almost always a license plate, a short unique key whose meaning lives in a database somewhere else. That is why twelve digits can stand for a product with a hundred attributes, why a grocer in 1974 could reprice ten thousand cans by editing one database row instead of pasting ten thousand stickers, and why the system degrades gracefully: a torn label gives no read, but the database behind a clean read can be updated forever without touching a package. The mark means: look me up. Everything else is somebody's software.
Quick answers
What do the bars in a barcode actually encode?
Widths. A scanner times how long reflected light stays dark or bright as it crosses the label; thin and thick bars and spaces, measured in modules, map to digit patterns in the symbology's table.
Why does a barcode sometimes not scan?
The common causes are poor contrast, damaged or smeared bars, wrong bar widths from bad printing, and anything printed in the quiet zone, the mandatory blank margin the scanner needs to find the symbol's edges.
Does a barcode contain the price?
No. A standard product barcode carries only an identifier. The price lives in the store's database; the stripe pattern means look me up, which is why repricing a product changes one database row, not ten thousand packages.
