Scanning head shines LED or laser light onto barcode.
Light reflects back off barcode into a light-detecting electronic component called a photoelectric cell. White areas of the barcode reflect most light; black areas reflect least.
As the scanner moves past the barcode, the cell generates a pattern of on-off pulses that correspond to the black and white stripes. So for the code shown here ("black black black white black white black black"), the cell would be "off off off on off on off off."
An electronic circuit attached to the scanner converts these on-of pulses into binary digits (zeros and ones).
The binary digits are sent to a computer attached to the scanner, which detects the code as 11101011.