Skip to story
ELI5 Yahaaa

Wide, narrow, wide

How Does a Shop Scanner Read a Barcode?

A barcode is a number written in stripes, and a scanner reads it by watching how much light bounces back.

Thirteen digits,written in stripesBlack absorbs, whitereflectsA beam sweeps acrossthe whole codeThe last digit checksthe other twelve
The stripes are the number. Nothing else is stored.
  1. Step 1 of 5

    The stripes are digits.

    A barcode on a packet 1011 Each digit is a patternof widths

    Every digit is drawn as a fixed-width slot containing two bars and two spaces of varying widths. Read the widths and you have read the number.

  2. Step 2 of 5

    The scanner watches reflected light.

    A beam sweepsacross Bright, dark,bright — thepattern of widths

    A beam sweeps across the label. Black bars absorb it and white gaps bounce it back, so the sensor sees a rapid on-off-on pattern as the beam crosses.

  3. Step 3 of 5

    The guard bars tell it where to start.

    1 Guard bars markthe ends2 Scanned fromeitherdirection3 Reversed andread correctly

    Extra bars at each end and in the middle mark the boundaries, and because the pattern is different at each end, a code scanned backwards is still readable.

  4. Step 4 of 5

    The last digit is a check on the rest.

    The sum agrees Accepted — one beepThe sum fails?Rejected silently — tryagain

    The final digit is calculated from the other twelve by a fixed sum. If the digits read do not produce it, the scanner rejects the read and simply says nothing.

  5. Step 5 of 5

    The code holds no price at all.

    A numberidentifying theproduct The shop'scomputer holds theprice

    It only identifies the product. The price lives in the shop's own computer, which is why the same tin can cost different amounts in two branches.

    A 13-digit EAN code has to be scanned correctly in full or not at all — the check digit catches roughly nineteen out of twenty single-digit misreads.

The short version

A barcode is a number written as stripe widths, read by watching reflected light, with a final digit that checks the read was right.

Try it yourself

Cover the last digit under a barcode and read the stripes above it. The pattern for that digit is still there — the printed number is only for humans.

Topics