Lesson 15 · Line Following


Suggested Time: 60-75 minutes

Lesson Plan

Overview

In this section we’ll learn how to use IR sensors to get our robot to follow a line!

What You’ll Need

Before we get started, let’s make sure that we have all the parts.

  • 1 x Arduino Uno Compatible Board
  • 2 x IR Sensor Modules
  • 6 x Pin to Socket Arduino Wires
  • 2 x Double-stick foam

Demo Video

IR Sensor Module

fig-3_4

IR Sensor modules include two special LEDs. One LED is a IR transmitter (the clear one) and the other is a IR receiver (the dark one).

The transmitter sends a IR signal into the air. While the IR travels through the air, it will bounce off of near by objects, sending IR back to the module. The IR receiver looks for any IR signals that are bounced back and reports back to your robot if it does - which means that there is an object near by.

There is a caveat here, though. If IR hits black color, it won’t bounce back because the black color absorbs the IR. We can use this caveat to tell the different between white and black!

Use two modules, and you now have the ability to cause the robot to follow a line!

Mounting Your Modules

Mount your modules to the front bumper using double-stick foam.

fig-3_4

Note: Newer versions include 2 x 90 degree angle mounts to ease mounting. See photos below for mounting instructions.

fig-3_4 fig-3_4
fig-3_4 fig-3_4

Wire Your IR Modules

The IR modules have three pins: VCC, GND and OUT.

VCC and GND provide power to the module. OUT is the signal that goes to the controller board, which our code will look at to see whether we see white or black.

Let’s wire the IR modules to your Arduino-Compatible board using the following connections.

Left Sensor Arduino-Uno Compatible Board
VCC 5V
GND GND
OUT 5
Right Sensor Arduino-Uno Compatible Board
VCC 5V
GND GND
OUT 6

fig-6_0

Troubleshooting Tips

  • Your rover may be heading in the wrong direction when it sees the line. If that’s the case, you probably have your left/right sensor mixed up. Check your wiring and code.
  • You may find that your rover reacts too slowly and and veers off the track before it can turn. If that’s the case, try slowing down your racer by moving at half speed. See lesson 8 if you need a refresher on how to do that.

Additional Resources