[quote author=Nick Gammon link=topic=93345.msg701524#msg701524 date=1329970548]
I have some example code on this page for that exact device (Rover 5):
Half-way down is stuff for reading the encoders.
You can use one pin (per wheel) but that just gives the speed. That might be all you need, the wheel is unlikely to be going the opposite way to the power you are applying to it.
On the Uno (and similar) you only get two external interrupts (D2/D3) so you can only read two wheels that way. However you could use pin-change interrupts, or make do with two wheel speeds (one on each side) to get the general idea of where the car is going (especially if you have the tracks version).
Thanks for the link to your code. I ended up creating a class for the motors and embedding the Teensy encoder class inside of it. But it only give encoder ticks+-.
I didn't use the XOR output and just the 2 encoder separate outputs with 1 being connected to a interrupt pin on the Mega 2560 and the 2nd on a regular digital pin, later will be a teensy2.0 ++
I was looking at your code to calculate speed. By having it constantly check speed does it affect encoder counts and since you reset the tick counts how would you calculate distance?