Arduino – Line following robot – part 3 (Optical sensors)

Arduino Logo
Print pagePDF pageEmail page

Part 3: Optical sensor board

After visiting many similar projects and testing loads of designs we settled down to use 3 sensors arranged as a triangle. Our assumptions of deciding the distances were based on:

  1. The board is white (formica)
  2. The standard 2cm black color electrical tape is used for the lines

Testing the prototype

Arduino Uno has 6 analog inputs, each at 10 bit resolution (giving 0 to 1023).

We used TCRT5000 reflective optical sensor to detect the black line. Here are the connections.

We used the following circuit to test our case with 3 scenarios. R2 was replaced with TCRT5000 optical sensor circuitry.

  1. Open to air
  2. Reflecting black (black electrical tape)
  3. Reflecting white (white paper)

Here’s the code we used to test our optical sensor. It simply reads the value on analog port 0 and send it back to the PC via the serial port. We used the excellent open source RealTerm serial port monitor to log the output. You could also use the built-in serial port monitor of the Arduino IDE (but this cannot save the output).

The 2 second delay is required for us to see the feedback of reflective object change. We used 9600 baud, 8 bit data without parity (default setting).

We received following results:

  1. Open to air – less than 50
  2. Reflecting black (black electrical tape) – less than 300
  3. Reflecting white (white paper) – more than 900

We were happy with the prototype and went ahead with building the final sensor board on Vero board.

Reading 3 analog sensors

The trick when using multiple analog sensors is to read them twice, with a small delay after each read (5ms is good), then discard the first reading. This is because the ADC multiplexer needs switching time and the voltage needs time to stabilize after switching.

Basically the first analogRead call causes the multiplexer to switch, the delay gives the voltage time to stabilize, then your second read should be much more accurate with less jitter.

More info here: http://arduino.cc/en/Tutorial/AnalogInputPins

We needed to detect the following patterns in order to traverse the path successfully.

  1. Sharp left turn
  2. Sharp right turn
  3. Left bend
  4. Right bend
  5. T junction
  6. Cross (or round-a-bout)

References:


Share

2 thoughts on “Arduino – Line following robot – part 3 (Optical sensors)

  1. Hello.
    I think that you have reversed the polarity of the LED in the schematics schema of the TCRT5000
    I checked other web sites and they had reverse polarity compared to yours and I was not able to make it work when I connected according to your schematic.

Leave a Reply

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