To detect wheel rotations in model vehicles, we would need to install some kind of sensors on the wheels to be monitored.

There are many different ways to achieve this. One could use a Hall effect sensor or some other kind of rotary encoders. One of the easiest way to achieve this though is to use a reflective optical sensor.

The following circuit shows one such design. It consist a transmitter (the infrared diode on the left) and a receiver. The receiver utilizes a PNP transistor as the output stage. The benefit of this design is that the output can achieve the TTL required logic level easily and the on-off transition is very sharp. When no infrared signal is received, the circuit output 0V and when a strong signal is received the circuit outputs 5V. Depending on the IR diode and the IR photo transistor used, this circuit can detect object with reflective surface up to several inches.

Simple Optical Encoder
Simple Optical Encoder

Here is the completed circuit board. A divider between the IR diode and the IR photo-transistor may be needed to reduce the interference.

Simple Optical Encoder
Simple Optical Encoder

The following picture shows the circuit board mounted on the underside of a toy car. I used a narrow strip of mirror as reflector to work with the optical detector.

Encoder Mounted on a Model Vehicle
Encoder Mounted on a Model Vehicle

Since I only used one mirror, this configuration can only send out one pulse per rotation. To improve the output resolution, you can construct a more sophisticated reflector pattern.

The Arduino code for this optical encoder is very simple as well. Every time a signal is received, the interrupt function wheelEncoderISR is called.

void setup() {
  attachInterrupt(0, wheelEncoderISR, FALLING);

void wheelEncoderISR() {
Be Sociable, Share!

5 Thoughts on “Simple Optical Encoder For Wheel Rotation Detection – I”

  • Hello Kerry,

    I am trying to come up with simple pulse optical encoder for a Sherline lathe. Did design this circuit? It is simple and very understandable. Could I use this design? Thank you for your time.

    Sonny Bolton

  • I tried your code and generate the following error: Arduino: 1.6.7 (Windows 10), Board: “Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)”

    \Arduino\Encoder_optic\Encoder_optic.ino: In function ‘void setup()’:

    Encoder_optic:2: error: ‘whellEncoderISR’ was not declared in this scope

    attachInterrupt(0, whellEncoderISR, FALLING);


    \Arduino\Encoder_optic\Encoder_optic.ino: In function ‘void wheelEncoderISR()’:

    Encoder_optic:7: error: expected primary-expression before ‘…’ token


    Encoder_optic:7: error: expected ‘;’ before ‘…’ token

    exit status 1
    ‘whellEncoderISR’ was not declared in this scope

    I would be grateful if you give me a little help.

Leave a Reply

Your email address will not be published. Required fields are marked *