We are currently trying to figure how to code and optical slotted sensor into an arduino program. the objective of our task is for a vehicle to drive forwards, reach a wall, and return to its original location, we have made an acrylic disk with holes, which sits on the front drive shaft which is connected to a small geared motor, to pass through the sensor. the sensor needs to count up and then when it reaches the wall a switch is thrown and it then counts down and reverses until it reaches zero again and it stops. If anyone has any advice or has made a similar program before any help would be greatly appreciated.
You can have a look here for some coding tips regarding encoders:
http://arduino.cc/playground/Main/RotaryEncoders