How a barcode is read
The stripes on a pack are a number with a built in check. See digits become bars, work out the check digit, make a typo and smudge the stripes to see what a scanner does.
Key takeaways
- A UPC-A code is 95 slots wide: three of guard, six digits of seven, five in the middle, six more digits and three of guard.
- The right half of the digit patterns is the left half turned inside out, so a scanner knows which half it sees.
- The twelfth digit comes from the other eleven: three times the odd places plus the even places, then ten minus the last digit.
- The check catches every wrong single digit and every swap of neighbours, except those that differ by exactly 5.
- A scanner uses the widths of the stripes, so the size does not matter. A smudge gives a pattern that is not a digit, or a code that fails the check.
Sources
Some of these sites could not be opened while this page was written, so some facts were checked through search results that quote them. The 7 slots of each digit, the guards of 3, 5 and 3 slots, the 95 slots in all, the first six digits on the left and the last six on the right, the right patterns being the left ones inverted, the check rule (3 times the odd places plus the even places, then ten minus the last digit modulo 10), the widths and not the size being what a scanner measures, the quiet zone, the first scan on 26 June 1974 in Troy, Ohio, Woodland and Silver in 1949 and Laurer’s rectangular design each appeared in at least two places. The ten patterns were checked against a table in one source for digits 0 to 5 and the rest follow the standard table. Sources differ on the right guard, on the kind of gum and its price, and on the exact day in 1973 when the code was chosen, so the page does not give that day. The claim that one changed digit is always caught and a swap of digits that differ by 5 is not comes from the sum, and is computed on the page. The counts of smudges are computed on the page for the code in the window.
- Aspose: UPC-AThe structure of a UPC-A code.
- Seagull Scientific: UPC-AThe guards and the digits.
- Tungsten Automation: UPC-AThe bit patterns of the digits.
- Yasoob Khalid: understanding UPC-AThe check digit sum.
- GS1 UK: how to calculate your check digitThe check digit rule.
- GS1 UK: the history of the barcodeWoodland, Silver and the first scan.
- IBM: the UPCLaurer and the rectangular design.
- History.com: the first barcode scanThe first scan on 26 June 1974.
- MIT Technology Review: behind barsHow the barcode was invented.
- Keyence: barcode mechanismsScanners measure widths.
- Leuze: bar code detectionThe quiet zone and the narrow element.