Picture it now. June 26th, 1974. You’re standing in a Marsh’s supermarket in Troy, Ohio. The smell of fresh produce in the air. The giant aisle of freezers at the back of the store are humming. The bright, almost white, incandescent lights are giving you a slight headache.

You can cut the tension in the air with a knife. There’s a small murmur and then a hush. The big moment is about to happen.

Everyone is watching. Holding their breath and slowly, subconsciously, leaning forward as a small, rectangular object heads slowly towards a pulsating red beam. This is the moment, where two years of effort by mathematicians, physicists, a consortium of grocery companies and researchers will come to fruition.

The Great Rectangle hits the red beam. A brief pause. Then an audible and pleasing “Boop.” Everyone freezes.

$0.69 appears on the National Cash Register screen. A 10-pack of Wrigley’s gum.

Hell yeah! The first UPC is scanned and automatically priced and let me tell you, this is one impressive accomplishment that I only came to appreciate recently. For a much better history, including source interviews, you must go read this excellent post, and the Dayton Daily News piece here.

As I was writing my first UPC Yeah You Know Me instalment, it dawned on me: I have no clue what a UPC actually is, where it came from, or what any of it means. So being the curious, ADHD (diagnosed) guy that I am, I thought it might interest others if I do an inappropriately deep dive into it.

#### The Birth of the UPC

As previously mentioned, it took over two years, and numerous revisions, by very smart people to come up with the mathematics, optics, physics, programming and a bunch of other stuff. Just to make those cool little barcodes spit that specific number out on a till, which is still happening billions of times a month, right now. It was a really tough problem it turns out.

The first attempts at barcodes were gigantic. At 104 square inches (roughly 10” x 10” or 25cm x 25cm), they would probably wrap around a product negating all those warnings and lists of ingredients that we all know and love…to ignore. As they progressed through various iterations of magic math, optical voodoo and various other sciencey things, they eventually landed on a final design that gave us the barcode and UPC system we know and love today.

But how the hell do they actually work?

#### Understanding How UPC Barcodes Work

UPC codes are pretty fascinating little units once you get to know them. Think of the entire UPC code as one big bucket, with two smaller buckets inside, that represent the *left *and *right *halves of the barcode and digits. The expertly drawn diagram below illustrates this:

This might already be quite a revelation to you, as it was to me. It is not one large, continuous barcode or one long continuous UPC number, instead, there are two halves to the number that are read independently. Neat right? Now check this out, a barcode also has special markers and sections named Start, Middle, End and the Quiet Zones.

If you visually look at a barcode, you’ll notice that the start, middle and end of the barcode markers are slightly longer than the rest of the barcode. Until I wrote this article, at 41 grizzled years of age, I had never noticed this. You will also notice that there is usually one number “outside” the bar code part (the number zero in this case, on the far left and the number two on the right). These numbers are in the "quiet zone” which is a precise length of whitespace, called *modules,* on either side that enables the reader to measure the total distance across the barcode.

##### Understanding UPC Modules

Modules are what give the barcode the alternating black and white pattern like piano keys, and let me tell you, they are cool as fuck. A module that is coloured black is called a *bar *and the white spaces are called a *space*. There are 95 (ninety-five) total modules in a UPC.

`Start Module 3 modules `*bar-space-bar*
Left Digits 42 modules
Middle Module 5 modules *space-bar-space-bar-space*
Right Digits 42 modules
End Module 3 modules * bar-space-bar*
Total 95 modules

The Quiet Zones are precisely 9 modules of space on the left and 9 modules of space on the right but are not counted in the total module count. Good so far? Now let’s take a look at how these geniuses colour those modules in a specific way in order to convert the bars and spaces to the corresponding digits.

##### Digit Encoding

Every digit in a UPC is made up of 7 modules, and how you colour the pattern of bars and spaces dictates what number is produced. The folks who designed and implemented UPC have a lookup table that lets anyone implement a reader that interprets the pattern of alternating bars and spaces.

Now things get wild. The digits on the left are in odd parity, what this means is that all of the digits on the left will have an odd number of * bars *in their 7-module pattern.

The digits on the right are even parity, which means that all of the digits on the right-hand side of the UPC will always be guaranteed to have an even number of * bars *in their 7-module pattern.

And why this weird pattern you may ask? Well, if you think about the last time you scanned something at a grocery store or you saw someone else do it, you just kind of waved the product around in front of that magical red beam, you heard that satisfying **boop** noise, the price comes up and you’re done.

The cashier (or yourself if you are using self-checkout) does not have to orient the product left-to-right or even right-side up. They just wave…and boop!

Wave…and boop!

The reason is because of that even/odd parity part. When the scanner reads the entire barcode, regardless of orientation, it simply takes one of the outermost 7 modules (making up a digit) and says: even or odd number of bars? If it is even then the scanner knows that it is dealing with right-hand digits and if it is odd, the left-hand digits. It then can orient to that and perform the rest of the reading.

It’s so cool! You can visually pick products up and * see *the digit encoding and look it up on the table linked below. I thought this was pretty neat. The final cool piece to this whole puzzle is that the numbers on the left and right are optical mirrors of each other, which means that for digit 0, you will have the bars coloured in the

*opposite*of the digit 0 on the left to the 0 on the right.

Pretty damn neat. What did we learn? Well, we learned how to take something seemingly simple (UPC), challenge that by trying to really go and understand it (The Hunt), become fascinated by the result (likely ADHD) and then share the fascination with someone else (what you’re reading).

More importantly? I just did a bunch of investigative and data visualization repetitions in a new way, learning about a new topic. Much like resistance training, the more reps, the more variety, the better it is. I encourage you to go off and try the same, and I hope you found UPCs as fascinating as I have.

#### Resources / Citations / Further Rabbit Holes

The First Barcode Scan in History and What It Tells Us About How Some Stories Make Us Care by Jim Wildman - medium

Dayton Inventions: The Barcode was Born in Troy 49 Years Ago - dayton daily news

Universal Product Code - wikipedia

Universal Product Code Encoding Table - wikipedia

All drawings - balsamiq.