Basically, when the scanner passes a black area it's a ZERO and when it passes a white area it's a ONE. (Maybe the other way around, but you get the point). The fundamental assumption is that the scan occurs at a constant speed, so that you can determine relative high/low times; speed is irrelevant. Knowing that, you can infer the ONES and ZEROS from the stream of high and low data.
It's actually a little more complex than that, but this explains more:
https://en.wikipedia.org/wiki/Universal_Product_Code
Hello barry, I called the oscilloscope and a network module that I can monitor via software.
I tested several codes, with 6 digits.
In the software, serial monitor, I get only 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00, always 20 hex and always in an average time between 60 68 72 92 milliseconds, depending on the way it I pass the code into the slot of the bar reader.
The only difference is that when I step slower or faster, the time in milliseconds to reach 00 changes, but always the beginning and the end are longer. But it's always 20 hex, which arrives on the serial monitor. Note, it's not UART, it's electrical pulses.
In the oscilloscope, the waves are square, and at the beginning and at the end they remain at a low level for a longer time.
I'm thinking about creating a logic, which may not be good, but it's a start: Monitor a pin for 100ms, and for 50 times, ie every 2ms I see if the pin is at High or Low level.
Once he's at a low level, it's obvious. If it's low level I store '0' in an array of 50, if it's high level I store '1' in another address of this array. That way I'll have 50 binary numbers to work with, and convert to decimal numbers. :-D