How do barcodes work?

A barcode is an optical, machine-readable, representation of data, or, in more simple words, a very rapid way of entering informations into a computer. The latter might be the electronic till in a supermarket or the computerised inventory in a warehouse. The advantages of using a barcode are obvious, with a simple scan a machine can detect all the informations about a product. However, all that computers can read and understand are sequences of 0 and 1. And it is on this binary combination relies the language of the barcode. To read the code, the machine relies on our old friend, the laser, a beam of pure light. A black bar does not reflect the laser light at all and it is recorded as a 1. The white bar reflect it very well and as such counts as a 0. A normal barcode in fact, looks precisely as a series of black bars and white spaces. This combination of bars represents a twelve digits number, which is also printed underneath, in case it becomes unreadable for wear and tear reasons.

The first number is the product type, such as a birthday card, newspaper or bottle of wine. The first five numbers are the manufacturer code, the next five numbers are the product code. The final number is the check digit, which is very important, but I will explain about it further on. At the beginning and at the end of the barcode there is a blank zone, which is necessary so that the scanner can work out the speed of your swipe. Another zone in the middle separates the left and the right parts of the code.

To recognise and identify different numbers, every space of the barcode is divided into seven individual modules. Every module can be filled with a black bar or rather be left blank. A thicker bar is nothing but a combination of two or more bars together, same goes for the wider white spaces. The combination of seven filled and blank spaces is read as a digit. For example the number one would be 0 0 1 1 0 0 1 or blank — blank — bar — bar — blank — blank — bar. Furthermore, there is some symmetrical cleverness going on. In fact, the numbers on the right hand side of the barcode are the optical opposite of the numbers on the left hand side. This is so the computer knows which way up the barcode is being held and does not interpret the code wrongly. So our previously mentioned number 1 for example, which was blank — blank — bar — bar — blank — blank — bar, is written on the right hand side becomes bar — bar — blank — blank — bar — bar — blank. And last but not least, do you remember the check digit? It is a necessary key to read the first part of the barcode correctly. The number is generated after the rest of the code via a mathematical expression. Firstly the computer adds together all the digits in the odd number positions and multiplies that total by three. To that total adds all the digits in the even number positions. The check digit is the number required to make this total the nearest number divisible by ten.

As a parting gift, a little bit of trivia for you. The first item scanned with a bar code was a packet of Wrigley’s Juicy Fruit chewing gums on the 26th of June 1974. It is now in a museum, still unchewed.