I've hooked up a Photo Reflector ( Photo Reflector SY-CR102 ) to my Arduino Uno 3. Its connected to analogue 0. Using a white card with some black stripes on it, I have held the card over the Photo Reflector and moved it back and forth. I can see that the analogue reading is changing rapidly from anything between 1023 down to 100 counts.
Question is how to I translate this into something useful I can use to read a kind of barcode from?
Not sure how to determine that. The card/sticker will be attached to the underside of a slot car. As the car moves over the sensor at any speed, I need to be able to read and decode the code…at least that’s the aim.
Then what you need to do is record when each HIGH to LOW and LOW to HIGH transition occurs. The time between the first and last transition defines the overall bar code length. Then, you can use the intermediate times to decide how wide a bar was. There are a fixed number of bars possible if the encoded number was 10101010101...01010. Knowing how many bars are possible defines the width of a bar (time-wise). Then, you can use the actual width to figure out how many 0s or 1s were read.