There is nothing really complicated about barcodes. Think Morse Code. When Samuel Morse invented the Morse Code back in 1835, it revolutionized long distance communications. Morse's code described a way of encoding text suitable for transmission via electric current over a wire. Each letter of the alphabet was reduced to a specific pattern of dots and dashes as shown in the following table.
|dit||1 unit of time|
|dah||2 units of time|
|pause between letters||3 units of time|
|pause between words||7 units of time|
So the letter 'S' for example, was decoded as dit dit dit. The letter 'O' became dah dah dah. These dits and dahs are often represented as dots and dashes. SOS then becomes:
Barcodes likewise have an alphabet of dots and dashes. These are represented as thin bars and wide bars separated by white space. UPC barcodes are one type of code. There are many others. A specific code is called a symbol set or symbology. In the UPC code, only the digits 0-9 are represented. Letters are not allowed. Each digit is represented as a specific pattern of thin and wide bars. (See UPC Specification)
Barcodes are "read" by a device called a "reader" or "scanner". These devices use reflected light off the barcode symbol to measure the widths of the bars and spaces.