How to use a rotary encoder with Arduino

Hi,

I just got a car kit ( http://dx.com/p/37-in-1-smart-car-chassis-kit-for-arduino-black-yellow-151814 ) with a provided "encoder wheel" (not the electronics part actually, just the mechanical part) and I need to use an encoder (to track my car's movement, as I want to make a semi-autonomous robot).

How can this be done with Arduino ? Using an IR sensor + interupts seem to be quite complex;

I've seen that there are some components that already implement a rotary encoder and that I'd just need to hook-up on my motor's axis to get the correct value (this for example : http://dx.com/p/octopus-rotary-encoder-brick-for-arduino-150690 ); Has anyone tried this ? Do you think it could work in my case ?

Thank you in advance !

seen Arduino Playground - RotaryEncoders ?

The library I use for mechanical rotary encoders is available at GitHub - dc42/arduino: Reusable modules, drivers and patches for the Arduino platform. I find that you need to poll them at least every 2ms to avoid missing transitions when they are spun quickly. I use either a cooperative scheduler (available from the same place) or a tick interrupt (which you can generate using the MsTimer2 library) to poll them every 1ms or 2ms. The library stores up the number of transitions counted, so you can call getChange() in your main program whenever it suits you, without losing transitions.