Figure 1. The line-following robot that you will build in this project.
So, how is the robot able to automatically track a dark line? The robot relies on a sensor that detects infrared (IR) light (which is part of the electromagnetic spectrum, just outside the range of visible light that humans can see). The sensor consists of two parts: an IR emitter which sends out IR light, and an IR detector, which detects incoming IR light. As shown in Figure 2, when combined, these two parts can be used to detect a nearby bright object, like white paper. The IR emitter sends out IR light, which bounces back off the white paper, and is "seen" by the IR detector. If the surface is too dark, the IR light will be absorbed by the surface instead of bouncing back from it, so the IR detector will not "see" any IR light.
Figure 2. An illustration of how the IR sensors in this project work. The IR emitter emits IR light. Bright surfaces will reflect this light back toward the IR detector and trigger the sensor, while dark surfaces will not.
Now you understand how an IR sensor can be used to detect a black line, but how do you actually get a robot to drive along and follow the line? You will need to use two of the sensors, one placed on either side of the line, as shown in Figure 3. Through an electronic circuit, each sensor controls the speed of one of the robot's two wheels. When both sensors "see" white, both wheels spin at full speed, causing the robot to drive straight. When one sensor sees the black line, it causes one of the robot's wheels to slow down, which makes the robot turn so it can continue to follow the line. For example, if the left sensor "sees" black, the left wheel slows down; this causes the robot to turn left. As shown in Figure 3, this allows the robot to automatically follow a curved track!
Figure 3. An illustration of how the line-following robot steers. It uses two IR sensors to detect the line. When a sensor "sees" the dark line, the circuit slows down the wheel on that side of the robot, causing the robot to turn.
In this robotics project, you will follow step-by-step instructions to build your own line-following robot. It turns out that the position of the IR sensors has a big impact on the robot's performance. If they are too close together (or too far apart), or too close to the floor (or too far above it), the robot might have trouble following the line. It could even overshoot a curve and crash! So, you will follow the Engineering Design Process to adjust your robot's sensors. Can you get it to drive without crashing?
Technical Note
The rest of the Introduction contains more details about the electronic components used in the circuit. The following information is provided as a reference, and you do not need to fully understand it in order to do the project. If are ready to just start building the robot, you can move on to the Procedure.
If you would like to read the rest of the Introduction, it will help if you are familiar with basic electronics terms like voltage, current, and resistance. Science Buddies has many beginner and intermediate level electronics projects, an Electronics Primer, and an Electricity, Magnetism, & Electromagnetism Tutorial that can help you learn more about these topics. You can also refer to the Bibliography for more information.
For a complete technical explanation of how the circuit works, including a circuit diagram, see the Help section.
The circuit you will build in this project uses a variety of electronic components. All of the components are combined on a chassis, or plastic base for the robot, which includes wheels. Some of the components, like batteries and switches, you probably use every day (even if you do not notice it). Others, like diodes and transistors, might be new to you if you have not done an electronics project before. Table 1 has pictures and descriptions of each component you will use in this project. For a more detailed explanation of what each component does in the circuit, see the Help section.
General robotics and electronics terms:
Circuit components:
Advanced terms (see Help section)
Itemname
Battery pack
Picture
Descripton
This is the power supply for your robot. Battery packs come in all shapes and sizes. The one in this project holds 4 AA batteries.
Breadboard
A breadboard allows you to quickly and easily connect wires and electronic components in order to build a circuit. The connections are not permanent, so you can easily move things around if you make a mistake.
Switch
You use switches every day to turn lights and appliances on and off. This is a tiny switch that fits on a breadboard, to let you turn your robot on and off.
Jumper wire
Jumper wires are short wires used to make electrical connections on a breadboard. They come with many colors of plastic insulation, which makes it easy to color-code and organize complicated circuits.
DC Motor
Electrical current causes a motor to spin. Two motors drive the robot's wheels. This type of motor runs on direct current (DC) from a battery (as opposed to alternating current [AC] from a wall outlet).
MOSFET
A MOSFET is a special type of transistor, which acts like a control valve to let electrical current flow. As an analogy, think of how a valve can control the flow of water through a garden hose. In this circuit, the MOSFETs control the flow of current through the motors. See the Help section for more detailed information about MOSFETs, including what MOSFET stands for.
Diode
A diode is like a one-way valve for electricity. It only lets current flow in one direction. In this circuit, diodes are used to protect the MOSFETs from voltage spikes that can be caused by abruptly stopping the motors.
Male-female jumper wire
This is a special type of jumper wire that comes with a female connector on one end and a male connector on the other end.
Resistor
As the name implies, a resistor resists the flow of electrical current. Electrical resistance is measured in ohms (Ω). Resistors come in many different values, marked by color-coded bands. In this project you will use 220 Ω resistors and 4.7 kΩ resistors.
IR sensor
The IR sensor consists of two parts, an emitter and a detector. The emitter is an IR light-emitting diode (LED), which emits IR light. The detector is an IR phototransistor, which is activated by the light. When combined, these two parts allow the sensor to detect nearby reflective objects, as shown in Figure 2.
Table 1. Pictures and descriptions of each circuit component used in this project.
How are all these components combined to control the motors and make the robot steer? While the full details are in the Help section, there are two things that will help you understand the basics of how the robot works:
Can you imagine how these two things could be set up to control a motor, and spin a wheel, based on whether or not the sensor sees a black line? You will need to connect the output of the sensor to the input of the MOSFET. Figure 4 shows a simplified diagram of this process (remember to refer to the Help section for the full explanation).