Go Down

#### SPlatten

##### Feb 09, 2012, 07:21 pm
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?
Kind Regards,
Sy

#### mkwired

#1
##### Feb 09, 2012, 08:37 pm
You need a way to measure the movement of the sensor relative to the card.

#### SPlatten

#2
##### Feb 09, 2012, 09:07 pm
In the application, the sensor will be fixed and the card will be moving rapidly over the sensor.
Kind Regards,
Sy

#### dxw00d

#3
##### Feb 09, 2012, 09:15 pm
You need to be able to work out the widths of the black lines, so you need to know how fast the card is moving.

#### SPlatten

#4
##### Feb 09, 2012, 09:18 pm
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.
Kind Regards,
Sy

#### dxw00d

#5
##### Feb 09, 2012, 09:33 pm
You might be able to use two sensors, and have a timing track of evenly spaced marks, to give an indication of speed or position.

#### PaulS

#6
##### Feb 09, 2012, 09:36 pm
Quote
Not sure how to determine that.

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.