Home Store Project Ideas Project Guide Ask An Expert Blog Careers Teachers Parents Students
Create Assignment

Build a Zippy Line-following Robot (BlueBot Project #3)

Recommended Project Supplies
Get Your Project Supplies
Get the right supplies — selected and tested to work with this project.
Skip the hassle of searching for supplies. Kit includes supplies hand-picked to deliver the best results for this project.
View Kit
Difficulty
Time Required Average (6-10 days)
Prerequisites You will need to know how to use a breadboard to do this project. See the Science Buddies reference How to Use a Breadboard if you have not used a breadboard before.
Material Availability A kit for this project is available from our partner Home Science Tools.
Cost High ($100 - $150)
Safety Short circuits can get very hot and present a burn hazard. Be careful to follow the directions in the Procedure in order to avoid short circuits when building your robot.

Abstract

How easy is it for you to walk along and follow a line that is painted on the ground? Simple, right? You might be able to follow a line without giving it much thought, but how could a robot do that? In this project, you will build your own automatic line-following robot that can race around a track that you create. This technology has plenty of real-world applications—maybe one day you could help design self-driving cars!

Objective

Build a line-following robot and make adjustments so it can follow a line on the floor without going off-course.

Credits

Ben Finio, PhD, Science Buddies
Circuit design by Howard Eglowstein, Science Buddies

  • LEGO is a registered trademark of The LEGO Group.
  • K'NEX is a registered trademark of K'NEX Limited Partnership Group.

Cite This Page

MLA Style

Science Buddies Staff. "Build a Zippy Line-following Robot (BlueBot Project #3)" Science Buddies. Science Buddies, 16 Oct. 2017. Web. 18 Nov. 2017 <https://www.sciencebuddies.org/science-fair-projects/project-ideas/Robotics_p023/robotics/line-following-robot>

APA Style

Science Buddies Staff. (2017, October 16). Build a Zippy Line-following Robot (BlueBot Project #3). Retrieved November 18, 2017 from https://www.sciencebuddies.org/science-fair-projects/project-ideas/Robotics_p023/robotics/line-following-robot

Share your story with Science Buddies!

I did this project I Did This Project! Please log in and let us know how things went.


Last edit date: 2017-10-16

Introduction

Have you ever walked along a line painted on the ground at a playground? Or have you ridden your bike along a trail, or ridden along a road in a car, with an adult driving? All of these things might seem pretty easy to do—you hardly have to think about them at all (although if you are going too fast or not paying attention, you might go off the trail or crash your bike!). How can you make a robot automatically follow a trail? There are many types of automatic, line-following or self-driving robots, ranging from the simple one you will build in this project (which follows a black line on a white floor), to completely automatic self-driving cars that can handle much more complex tasks, like stopping at red lights and avoiding other cars. These more-advanced cars and robots use sensors, like cameras, to observe the world around them and know how to react—just like you use your eyes (or a visually impaired person would use a cane and their sense of touch) to observe a trail or path in front of you. The robot you build in this project will use two sensors and a simple circuit that allows it to steer left and right to follow a line. Figure 1 shows what the robot will look like, and the video shows a demonstration of how it works.

line following robot
Figure 1. The line-following robot that you will build in this project.

A video demonstration of the line-following robot.

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.

infrared light reflective object sensor
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!

how steering works for a line following robot
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.

Item NamePicture Description
Battery pack
4xAA battery holder
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
breadboard picture
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
SPDT 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
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
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
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
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
male-female jumper wires
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
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
IR emitter detector
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:

  • The MOSFETs act like valves that control flow of electricity through the motors. When a MOSFET's input receives a high voltage, it makes a motor turn on, which spins a wheel. When a MOSFET's input receives a low voltage, it makes the motor shut off, so the wheel stops.
  • The IR sensor can be set up so it outputs a high voltage when it "sees" white, and a low voltage when it "sees" black.

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).

line following robot behavior block diagram
Figure 4. A block diagram of the robot's operation (this is a simplified diagram that excludes some components; see the Help section for the actual circuit diagram).

Terms and Concepts

General robotics and electronics terms:

  • Sensor
  • Circuit
  • Infrared (IR) light
  • Electromagnetic spectrum
  • IR emitter
  • IR detector
  • Voltage
  • Current
  • Resistance
  • Chassis

Circuit components:

  • Battery pack
  • Breadboard
  • Switch
  • Jumper wires
  • Male-female jumper wire
  • DC motor
  • MOSFET
  • Transistor
  • Diode
  • Resistor
  • Ohm (Ω)
  • IR sensor
  • Light-emitting diode (LED)
  • Phototransistor

Advanced terms (see Help section)

  • Base
  • Collector
  • Emitter
  • Bipolar transistor
  • Field-effect transistor
  • Gain
  • Gate
  • Drain
  • Source
  • Threshold voltage
  • Saturation
  • N-channel MOSFET
  • P-channel MOSFET
  • Current-limiting resistor
  • Pull-down resistor

Questions

  • What real-life conditions and obstacles do self-driving cars have to deal with?
  • What types of sensors do self-driving cars use to help them drive?
  • How are real-world self-driving cars different from the robot you will build in this project?
  • How can an IR light sensor be used to detect a dark line and help a robot follow it?
  • How do you think changing the IR sensors' distance from the ground will affect the robot's steering?
  • How do you think changing the horizontal distance between the IR sensors will affect the robot's steering?

Bibliography

These beginner references will be useful if you are just starting out with electronics and robotics:

These references will be useful for students who want to learn more about how the circuit works, and about electronics in general:

These references contain specific information about some of the circuit components used in this project:

News Feed on This Topic

 
, ,
Note: A computerized matching algorithm suggests the above articles. It's not as smart as you are, and it may occasionally give humorous, ridiculous, or even annoying results! Learn more about the News Feed

Materials and Equipment Product Kit Available

  • BlueBot: 4-in-1 Robotics Kit, available from our partner Home Science Tools. You will need the following components from the kit (the kit also contains additional parts for three other projects). See the Background tab for pictures if you are not sure what a part looks like.
    • Blue plastic robot chassis (includes wheels, motors, and 4xAA battery holder)
    • 3xAA battery holder (this is used in place of the 4xAA battery holder if your robot is going too fast)
    • AA batteries (4)
    • Breadboard
    • Jumper wire kit
    • Power switch
    • Diodes (2)
    • MOSFETs (2)
    • 150 Ω resistor (2) (brown, green, brown, gold stripes)
    • 220 Ω resistors (2) (red, red, brown, gold stripes)
    • 4.7 kΩ resistors (2) (yellow, purple, red, gold stripes)
    • IR sensors (2)
    • Male-female jumper wires (8)
  • You will also need the following materials, not included in the kit:
    • Small Phillips-head screwdriver
    • Double-sided foam tape
    • Optional: Wire cutters (can be used to shorten the metal leads on some parts of your circuit, making the circuit "neater")
    • Optional: Needle-nose pliers or tweezers (make it easier to handle small circuit components)
    • Popsicle sticks (2), or building toy pieces like LEGO® or K'nex® (used to attach the IR sensors to the front of your robot)
    • Hot glue gun or duct tape
    • Clear tape
    • Flat, open floor space to make a line-following track
    • White posterboard (at least 4 pieces that you can arrange in a 2x2 grid on the floor). If you have more floor space, you can make a larger track with a 3x3 or even a 4x4 grid.
    • Black electrical tape or a large, black permanent marker
    • Scissors
    • Lab notebook
 Recommended Project Supplies
     Get Your Project Supplies
Get the right supplies — selected and tested to work with this project.
Skip the hassle of searching for supplies. Kit includes supplies hand-picked to deliver the best results for this project.
Project Kit: $109.95
View Kit

Remember Your Display Board Supplies

ArtSkills sparkle letters

Holographic Poster Letters

ArtSkills buy now button
ArtSkills vinyl letters

Vinyl Letters & Numbers

ArtSkills buy now button
ArtSkills supplies trifold

ArtSkills Trifold with Header

ArtSkills buy now button

Share your story with Science Buddies!

I did this project I Did This Project! Please log in and let us know how things went.

Experimental Procedure

Note: This engineering project is best described by the engineering design process, as opposed to the scientific method. You might want to ask your teacher whether it's acceptable to follow the engineering design process for your project before you begin. You can learn more about the engineering design process in the Science Buddies Engineering Design Process Guide.

Assembling Your BlueBot Chassis

  1. Follow the instructions in the video to assemble your robot chassis.
    1. Note that your kit does come with printed directions for assembling the chassis, but we recommend watching the video so you fully understand how all the parts fit together.
    2. Note that we recommend using double-sided foam tape to attach the battery holder to the top of the chassis, as shown in Figure 5. The printed directions recommend putting the battery holder in-between the two chassis plates, but this makes it harder to change the batteries.

assembled bluebot robot chassis
Figure 5. A completed BlueBot chassis with breadboard and battery pack on top.

Assembling Your Circuit

  1. To build your circuit, you will need to know how to use a breadboard. Watch the video and see the Science Buddies reference How to Use a Breadboard.
  1. Now that you know how to use a breadboard, you are ready to assemble your BlueBot circuit. Table 2 shows a list of all the components in the circuit and where they go on the breadboard. You can download and print a PDF of this table—complete with checkboxes to track each step—to use while you are building your robot. You can also view a slideshow that shows breadboard diagrams of the circuit. Follow along in the table and/or slideshow to build your circuit one component at a time. Your finished circuit should look like the one in Figure 6. Pay attention to these notes:
    1. Remember to push all components firmly into the breadboard.
    2. All references to orientation (up, down, left, and right) assume you have the breadboard "right-side up," so the writing is facing you.
    3. Your jumper wire kit comes with an assortment of colors, and the colors may vary. It does not matter what color jumper wires you use. Your colors do not need to match the colors in the diagrams.
    4. You will use male-female jumper wires to connect the IR sensors to the breadboard. These wires act like "extension cords" that allow you to attach the sensors to the front of your robot, so they can look down at the ground in front of the robot. You do need to keep track of the wire colors when connecting the IR sensors, since you need to connect the four pins in the right order.
    5. Insert the batteries last. If you see or smell smoke when you insert the batteries, you have a short circuit somewhere. Immediately remove the batteries and recheck your wiring.
Component Picture Symbol Breadboard holes Note
Power switch
SPDT switch
switch symbol
F1, F2, F3 Direction in which it is facing does not matter, but make sure to slide switch down (toward row 30, away from row 1), this is the "off" position.
Jumper wire
jumper wire
jumper wire symbol
J2 to (+) bus Color does not matter.
Jumper wire
jumper wire
jumper wire symbol
Left side (+) bus to right side (+) bus Color does not matter.
Jumper wire jumper wire jumper wire symbol Left side (-) bus to right side (-) bus Color does not matter.
MOSFET MOSFET mosfet breadboard symbol C11, C12, C13 Writing should face to the left, large silver tab should face to the right.
Note: the writing on your MOSFET might not match the picture exactly. This is OK.
MOSFET MOSFET mosfet breadboard symbol C18, C19, C20 Writing should face to the left, large silver tab should face to the right.
Note: the writing on your MOSFET might not match the picture exactly. This is OK.
Jumper wire jumper wire jumper wire symbol A13 to (-) bus Color does not matter.
Jumper wire jumper wire jumper wire symbol A20 to (-) bus Color does not matter.
Diode diode diode breadboard symbol A12 to (+) bus Gray band must face to the left.
Optional: Shorten the leads.
Diode diode diode breadboard symbol A19 to (+) bus Gray band must face to the left.
Optional: Shorten the leads.
4.7k Ω resistor 4.7 k resistor picture 4.7k resistor symbol A11 to (-) bus Direction does not matter. Make sure you pick the right color bands! (yellow, purple, red, gold)
4.7k Ω resistor 4.7 k resistor picture 4.7k resistor symbol A18 to (-) bus Direction does not matter. Make sure you pick the right color bands! (yellow, purple, red, gold)
220 Ω resistor 220 resistor picture 220 resistor breadboard symbol A5 to (+) bus Direction does not matter. Make sure you pick the right color bands! (red, red, brown, gold)
220 Ω resistor 220 resistor picture 220 resistor breadboard symbol A25 to (+) bus Direction does not matter. Make sure you pick the right color bands! (red, red, brown, gold)
Top IR sensor IR emitter detector IR sensor breadboard symbol Black wire to (-) bus
Red wire to (+) bus
Blue wire to B5
Green wire to B11
There is a small notch in one corner of the black plastic case. Place notch in top right with pins facing you. Clockwise from top right, connect red, green, blue, and black wires.
Note: the writing on your sensor might not match the picture exactly. This is OK.
Bottom IR sensor IR emitter detector IR sensor breadboard symbol Black wire to (-) bus
Red wire to (+) bus
Blue wire to B25
Green wire to B18
There is a small notch in one corner of the black plastic case. Place notch in top right with pins facing you. Clockwise from top right, connect red, green, blue, and black wires.
Note: the writing on your sensor might not match the picture exactly. This is OK.
Top motor DC motor motor symbol Red lead to (+) bus
Black lead to E12
When the robot is driving forward, this is the "right" motor.
Bottom motor DC motor motor symbol Red lead to (+) bus
Black lead to E19
When the robot is driving forward, this is the "left" motor.
Battery holder 4xAA battery holder battery holder symbol Red lead to J1
Black lead to (-) bus
Do not insert batteries until circuit is complete.
AA battery AA battery battery symbol N/A Insert into battery holder. Make sure (+) signs on batteries line up with (+) signs in battery holder.
Table 2. List of circuit components and locations. A printable PDF version is available.

slideshow-bluebot-line-1 slideshow 2 line tracking robot circuit slideshow 2 line tracking robot circuit slideshow 4 line tracking robot circuit slideshow 5 line tracking robot circuit slideshow 6 line tracking robot circuit slideshow 7 line tracking robot circuit slideshow 8 line tracking robot circuit Insert diode into hole A12 and (+) bus. Gray stripe must face toward (+) bus. Insert diode into hole A19 and (+) bus. Gray stripe must face toward (+) bus. slideshow 11 line tracking robot circuit slideshow 12 line tracking robot circuit slideshow 13 line tracking robot circuit slideshow 14 line tracking robot circuit Connect top IR sensor to (-) bus (black wire), (+) bus (red wire), B5 (blue wire), B11 (green wire). Connect bottom IR sensor to (-) bus (black wire), (+) bus (red wire), B25 (blue wire), B18 (green wire). slideshow 17 line tracking robot circuit slideshow 18 line tracking robot circuit slideshow-19-line-tracking-robot-circuit notch in corner of IR sensor, IR sensor jumper wire connections
slideshow 0 line tracking holder
Click through the slideshow for step-by-step breadboard diagrams of the circuit.


completed circuit line following robot circuit
Figure 6. Your completed circuit should look like this.
  1. Use popsicle sticks or building toys like LEGOs or K'nex to mount the IR sensors to the front of your robot, as shown in Figure 7. Use double-sided foam tape to attach the sensors and do not permanently glue them in place yet, as you may need to adjust them later. The sensors should be about 2 cm apart and 1 mm off the ground. Adjusting the exact position of the sensors to get your robot working will be part of the engineering design process.

line sensors attached to the front of a line following robot
Figure 7. Sensors mounted to the front of the robot using double-sided foam tape and popsicle sticks.

Testing Your Robot

You are finally ready to start testing your robot! Remember that now you will need to follow The Engineering Design Process to get your robot working. Follow these steps to learn how to use your robot.

  1. Double-check your circuit against the breadboard diagrams in the previous section. Remember that just one misplaced wire can prevent the circuit from working properly.
  2. Hold the robot's chassis in one hand, so the wheels are off the ground and the IR sensors are up in the air (not close to any surface).
    1. Turn the robot's power switch "on" by sliding it up, toward row 1 on the breadboard.
    2. One at a time, hold a piece of white scrap paper in front of each of the IR sensors. Slowly move the paper toward the sensor until it is almost touching. This should cause the wheel on that side of the robot to start spinning. Check Table 3 to see what you should do next.
Observation What to Do
I see or smell smoke. Immediately turn your robot off. You have a short circuit somewhere. Recheck your wiring against the breadboard diagrams in the previous section.
Each wheel spins forward when I hold a piece of white paper in front of the IR sensors. Your robot works! Move on to the next step.
One or both wheels spin backwards when I hold a piece of white paper in front of the IR sensors. Reverse the red and black wires of the motor if the wheel is spinning backwards.
The wheels do not spin at all when I hold a piece of white paper in front of the IR sensors. You have an error somewhere in your circuit. Go back and double-check your wiring against the breadboard diagrams. Be especially careful that you connected the IR sensors correctly.
The wheels still do not spin at all even when I double check my wiring. See the Help section for more detailed troubleshooting information.
Table 3. Troubleshooting procedure for the first time you turn on your robot.
  1. Turn your robot off for now. For your first test, you will see if it can follow a straight line.
    1. Create a straight line on a piece of white posterboard using a thick black marker or electrical tape, as shown in Figure 8.
    2. Place your robot down at one end of the line, with the IR sensors straddling either side of the line.
    3. Turn the robot on. It should drive forward and stay over the line. You may notice that if it starts drifting to one side, it corrects itself and turns back toward the line.
    4. If your robot does not stay over the line, you may need to adjust the IR sensors. This is where the engineering design process comes in, because there is no single "right answer." A general rule of thumb is that the sensors should be as far apart as your line is thick (for example, 2 cm apart if you draw a 2 cm thick line with a permanent marker), and about 2–3 mm off the ground. However, the exact distances can depend on things like lighting in the room (sunlight contains some infrared light, which can affect the sensors) and the surface you are using (some posterboard has a "glossy" surface, which is more reflective than posterboard with a "matte," or dull, surface). So, you may need to adjust the sensor spacing until you can get your robot to work.
    5. You can test how well your sensors are working by holding your robot just above the paper (so the wheels are not touching the ground). When you hold the sensors over the white paper, the wheels should spin forward. When you hold them over the black line, the wheels should stop.
line following robot on a straight line
Figure 8. A straight line to test your robot's line-tracking abilities.
  1. Now see if your robot can follow a curved line. Create a line with some gradual curves like the one in Figure 9. Your robot will not work well with very tight curves or angles. Test to see if your robot can follow the curved line. Can it make the turns, or does it "overshoot" the turns and drive off the track? If your robot overshoots the curves, the easiest thing to try is to make the line thicker. This will make it harder for the robot to drive over the line without one wheel stopping. See Table 4 for more troubleshooting suggestions if your robot will not follow a curved line.
line tracking robot on a curved line
Figure 9. A simple curved line for your robot to follow.

Observation What to Do
My robot can follow curved lines. Your robot works! Move on to the next step.
My robot overshoots curved lines and drives off the track. Try making the line thicker, or make more gradual curves. This will make it harder for the robot to drive over the line without one wheel stopping.
My robot still overshoots turns even when I make the line thicker or make the curves more gradual. You need to slow your robot down. Go to the Troubleshooting section.
Table 4. Troubleshooting for getting your robot to follow curved lines.
  1. Once your robot can follow basic straight and curved lines, you can piece these together to make a larger track, like the one in Figure 10. How complicated of a track can your robot follow? How many "laps" can it complete before it drives off the track? If you run into trouble getting your robot to follow the line, check out the Troubleshooting section.
line tracking robot course
Figure 10. A complete track for a line-following robot.

Troubleshooting: My robot will not follow the line!

One of the most common problems with the line-following robot is that it goes too fast to make turns. It will drive right over the black line and just keep going! If you have space to make a very large track with very gradual turns, this might not be a problem. But, if you have limited space and have to make a track with tighter turns, you might need to slow your robot down. You can do this by supplying less voltage to the motors, which makes them spin slower. To do this, you need to swap out the battery pack and two of the resistors in your circuit.

  1. Replace the 4xAA battery back with the 3xAA battery pack that is included in your BlueBot kit, as shown in Figure 11. AA batteries provide 1.5 volts (V) each. So, four AA batteries provide 6 V to the motor, while 3 AA batteries only provide 4.5 V. This lower voltage will make the motors slow down.
3xAA battery pack for line following robot
Figure 11. Replace the 4xAA battery pack with the 3xAA battery pack.
  1. Replace the 220 Ω resistors (red, red, brown, gold) with 150 Ω resistors (brown, green, brown, gold), as shown in Figure 12.
    1. These are the "current limiting resistors" for the IR LED in the IR sensor. Since you are decreasing the supply voltage to the LED, you also need to decrease the value of the current limiting resistor. Do an internet search for "LED resistor" if you want to learn more about this topic.
150 ohm resistor for line following robot
Figure 12. Swap out the 220 Ω resistors for 150 Ω resistors (circled in green).
  1. Test your robot again. It should move slower and have an easier time making turns. If it still overshoots turns, remember that you should also try making the line thicker.
  2. Advanced: If your robot is still going too fast, you can try slowing it down even more by decreasing the voltage to 3 V. Your BlueBot kit does not include a 2xAA battery pack, so to do this, you will have to remove a battery from the 3xAA pack, and then "short out" one of the connections using a jumper wire, as shown in Figure 13.
convert 3xAA battery holder to 2xAA battery holder using a jumper wire
Figure 13. To reduce the battery voltage to 3 V, you need to remove one battery from the 3xAA battery holder and insert a jumper wire in its place.
  1. Your kit does not include any resistors smaller than 150 Ω. To decrease the current-limiting resistance, you will need to add two more 150 Ω resistors next to the two that are already in your circuit, as shown in Figure 14.
    1. This is called putting resistors "in parallel," and it actually decreases the total resistance. To learn more about this topic, do an internet search for "resistors in series and parallel."
Add two more 150 ohm resistors in parallel
Figure 14. Add two more 150 Ω resistors in parallel to the first two in order to decrease the current-limiting resistance for each LED when the batteries are only supplying 3 V.
  1. Test your robot again. It should move much more slowly.

Explore More!

Looking for more robot fun? Explore the World of Robotics with This Suite of Projects!

Troubleshooting

For troubleshooting tips, please read our FAQ: Build a Zippy Line-following Robot (BlueBot Project #3).

Communicating Your Results: Start Planning Your Display Board

Create an award-winning display board with tips and design ideas from the experts at ArtSkills.
ArtSkills button poster gallery 350
ArtSkills button design tips 350
ArtSkills button for more tips 210 h

Share your story with Science Buddies!

I did this project I Did This Project! Please log in and let us know how things went.

If you like this project, you might enjoy exploring these related careers:

female robotics engineer adjusting robot

Robotics Engineer

Have you watched "The Transformers" cartoon series or seen the "Transformers" movies? Both shows are about how good and evil robots fight each other and the humans who get in the middle. Many TV shows and movies show robots and humans interacting with each other. While this is, at present, fantasy, in real life robots play a helpful role. Robots do jobs that can be dangerous for humans. For example, some robots defuse landmines in war-stricken countries; others work in harsh environments like the bottom of the ocean and on the planet Mars. At the heart of every robot is a robotics engineer who thinks about what a robot needs to do and works with several engineering disciplines to design and put together the perfect piece of equipment. Read more
robotics technician

Robotics Technician

Robots are no longer futuristic machines. Robots are here and now and are used in manufacturing, health care, service industries, and military applications. They perform tasks that are repetitive and hazardous—things that humans don't want to do or are unsafe to do. But robots are still machines, which means they require humans to build, maintain, program, and keep them functioning efficiently. Robotics technicians work with robotics engineers to build and test robots. They are responsible for installing and maintaining robots and keeping them in working order for their employers. If you are interested in working with robots, your future is here and now. Read more
electrical engineer aligning laser

Electrical & Electronics Engineer

Just as a potter forms clay, or a steel worker molds molten steel, electrical and electronics engineers gather and shape electricity and use it to make products that transmit power or transmit information. Electrical and electronics engineers may specialize in one of the millions of products that make or use electricity, like cell phones, electric motors, microwaves, medical instruments, airline navigation system, or handheld games. Read more
Mechanical engineer building prototype

Mechanical Engineer

Mechanical engineers are part of your everyday life, designing the spoon you used to eat your breakfast, your breakfast's packaging, the flip-top cap on your toothpaste tube, the zipper on your jacket, the car, bike, or bus you took to school, the chair you sat in, the door handle you grasped and the hinges it opened on, and the ballpoint pen you used to take your test. Virtually every object that you see around you has passed through the hands of a mechanical engineer. Consequently, their skills are in demand to design millions of different products in almost every type of industry. Read more


Variations

  • There are three other projects you can do with your BlueBot kit. Since you have already assembled your chassis, all you need to do is build a new circuit.
  • A "bristlebot" is a small robot that uses vibration motors instead of geared DC motors, and toothbrush heads instead of wheels. You can put the same circuit you used in this project on a bristlebot to build a miniature version of the robot. Science Buddies has directions for building a light-tracking bristlebot in the Build a Light-Tracking Bristlebot project (the circuit is identical to the one used in the Light-Tracking Bluebot project). Can you adapt the bristlebot to have a line-following circuit instead?
  • The Arduino is a very popular type of microcontroller used in robotics. It lets you write a computer program that can read inputs from sensors and use them to control motors. This gives you more precise "control" over your robot's behavior. Can you build a programmable line-tracking robot by adding an Arduino to your chassis? See our Getting Started with Arduino page to learn more.
  • Instead of using the plastic chassis that came with your BlueBot kit, you can build your own chassis using materials like foam and cardboard, like the one shown in Figure 15. The circuit for the robot remains the same—only the chassis is changed. Can you design and build an improved chassis?
A simple line following robot that uses two sensors, one on either side of a black line drawn on the floor.
Figure 15. An example of a homemade chassis.

Explore More!

Looking for more robot fun? Explore the World of Robotics with This Suite of Projects!

Share your story with Science Buddies!

I did this project I Did This Project! Please log in and let us know how things went.

Frequently Asked Questions (FAQ)

If you are having trouble with this project, please read the FAQ below. You may find the answer to your question.
Q: My robot does not move at all when I put it down on the track and turn it on. What should I do?
A: If your robot does not move at all, try the following:
  • Try holding the robot chassis in your hands so the wheels are free to spin. Hold a small piece of white paper in front of one of the IR sensors, and slowly move it back and forth. Then try this for the other sensor.
    • If the wheels start spinning, you know your circuit is working.
    • If the circuit is working properly, but the robot does not move at all when you put it on the floor, the problem is probably the distance of your IR sensors from the floor. They might be too far away or too close. Adjust this distance and then try again.
    • If the wheels do not spin, even when you are holding the robot, there may be a problem with your circuit. Go to the next bullet point.
  • Double-check all of your breadboard connections. Make sure every lead and jumper wire is firmly pressed into the breadboard. Make sure all of your connections match the breadboard diagrams from the Procedure. You can read about other common breadboard mistakes in the the Common Mistakes section of our breadboard tutorial.
  • Make sure all your batteries are properly inserted into the battery holder, with the "+" symbols on the batteries lined up with the "+" symbols inside the holder.
  • If you have been using your robot for a long time, or did some of the other BlueBot projects first, your batteries may be dead. Try putting fresh batteries in your robot if none of the other steps work.
  • If your robot still does not turn on, follow these steps to see if the problem is with your power switch:
    • Remove the power switch from the breadboard, flip it around, and put it back into the same breadboard holes (F1, F2, and F3). If you are confused about which way to rotate the switch, see this video.
    • Slide the power switch to the "on" position ("up" towards row 1 of the breadboard) and try testing your robot again. If your robot works after making this change, you can continue with the project, but please contact us at scibuddy@sciencebuddies.org to let us know this happened.
    • If your robot still does not work after flipping the power switch around, bypass the power switch entirely. Connect the battery pack's red lead directly to the breadboard's power bus instead of hole J1. This connects the battery pack directly to the rest of the circuit. To turn the robot off again, you will have to temporarily disconnect this wire.
    • Now, re-try testing your robot. If your robot works, you can continue with the project, but please contact us at scibuddy@sciencebuddies.org to let us know the switch did not work in either direction.
    • If your robot still does not work, even after you have tried the previous steps, the problem is elsewhere in your circuit and not with the power switch. If you are having trouble figuring out what is wrong with your robot, you can ask a question in our Ask an Expert: Answers to Your Science Questions forums.
Q: Only one of my robot's wheels is spinning. What is wrong?
A: Your robot's circuit consists of two identical halves that drive the two motors. If only one wheel is spinning, chances are you just have something placed incorrectly on the breadboard in one half of the circuit. Very carefully double-check all of your writing on the side of the motor that is not working. It only takes one misplaced component or jumper wire to prevent the motor from spinning! Whether the motors spin properly also depends heavily on the distance between the IR sensors and the ground. If a sensor is touching the ground so its face is totally blocked, or if it is too far away from the ground, then it will not detect any reflected IR light and the wheel on that side will not spin. Try adjusting the distance between your sensors and the ground.
Q: My robot is going backwards! What should I do?
A: If your robot is going backwards, you just need to switch the red and black leads for each motor. This will cause the motors to spin in the opposite direction. These connections are shown in Figure 15.
line tracking robot circuit diagram motors


line tracking robot diagram with motor leads reversed
Figure 15. In the top image, the motors' red leads are connected to the power bus, and the black leads are connected to the MOSFETs' drain pins (holes E12 and E19). If this configuration causes your robot to go backwards, just switch the red and black wires for each motor, as shown in the bottom image. Connect the black wires to the power bus, and the red wires to holes E12 and E19. Do not worry about violating the color-coding convention for positive and negative; all this does is reverse the direction in which the motors spin.
Q: I have double-checked everything and my robot still does not work. How can I check if something is broken?
A: If you are having trouble figuring out why your robot will not work, you can try asking a question in our Ask an Expert: Answers to Your Science Questions forums. If you have access to a multimeter, you can also use that to help troubleshoot your circuit. See the Science Buddies reference How to Use a Multimeter if you need help using a multimeter. There are several steps you can take to check individual parts of your circuit (depending on your multimeter's probes, you may need alligator clips and additional jumper wires to take these measurements).
  • Try plugging your motor's leads directly into the buses on your breadboard (for each motor, one lead to the power bus, one lead to the ground bus). If the motors turn on, then you know that they are working, and the problem is elsewhere in your circuit. If the motors do not turn on, that does not necessarily mean they are broken. There might be a problem with your power supply (see next point).
  • Check your breadboard's power supply.
    • Set your multimeter to measure DC volts. Four fresh AA batteries should provide just over 6 V.
    • Turn your power switch on and measure the voltage between the breadboard's buses. If you do not read a voltage, there may a problem with your power switch (see the first question in this FAQ), but you should also double check that your power switch and the red jumper wire from hole J2 to the power bus are in the right place.
    • Unplug the red and black battery pack leads and measure the voltage of the battery pack directly. If you get a reading, then you know your battery pack is working, and the problem is with your breadboard connections or the power switch. If you do not get a reading, make sure all the batteries are in the correct orientation in your battery pack, and that none of the metal clips and springs that hold the batteries in place are loose.
  • Make sure the IR LEDs in the IR sensors are working.
    • Connect your multimeter in series with the IR LED (meaning, between pin 4 of the IR sensor and ground, or between the 220 Ω resistor and pin 3 of the sensor), and measure current when the robot is switched on. You should measure about 20 mA. If no current is flowing at all, the LED may be burned out, or it might not be receiving power (see above).
    • If your multimeter has a diode test function, you could also use that to test the LEDs.
  • Test the output of the phototransistors.
    • Measure the voltage between pin 2 of an IR sensor and ground (make sure the robot is turned on). When the sensor is aimed at a dark surface, or is very far away from a light surface, this voltage should be close to zero. When the sensor is held close to a white surface, the voltage should increase (to almost the battery pack voltage, but not quite). If this voltage does not change, the phototransistor may not be properly receiving power.
  • If the motors work when you plug their leads directly into the buses, and the output voltage of the IR sensors increases when they are held close to a white surface, then the problem is elsewhere in your circuit. You know the individual components work so nothing is "broken." Double and triple-check your wiring. Remember that just one misplaced wire can prevent the entire circuit from working.
Q: How can I get my robot to slow down so it can follow lines more easily?
A: See the Troubleshooting section in the Procedure.
Q: How does the IR sensor work?
A: The IR sensor consists of an infrared LED and an infrared phototransistor. A regular transistor has three pins: the base, collector, and emitter, as shown in Figure 16 (note: technically this is a bipolar transistor, which is slightly different from a field-effect transistor; see the next bullet point). Normally, when a small current is applied to the base pin, this causes a larger current to flow between the collector and emitter pins. The ratio between these two currents is called the gain (note: the transistor must be connected to a power supply; current will not just flow on its own). A phototransistor is activated when the base pin is exposed to light instead of current. So, when light from the IR LED is reflected back toward the sensor, it hits the base of the phototransistor, causing a larger current to flow. This triggers the gate pin of the MOSFET, activating the motors. You can read more about the IR sensor on its datasheet.
How a bipolar transistor works
Figure 16. Diagram of a bipolar transistor. It has three pins: the base, collector, and emitter. Normally, a small current applied at the base causes a larger current to flow between the collector and emitter. A phototransistor is activated by light instead of electrical current.
Q: How does a MOSFET work?
A: MOSFET stands for metal-oxide-semiconductor field-effect transistor (so you can see why it is a lot easier just to say "MOSFET"). The three pins of a field-effect transistor are called the gate, drain, and source. Unlike a bipolar transistor, which is controlled by a small current applied to the base pin, a field-effect transistor is controlled by a voltage applied to the gate pin, but the gate does not actually draw any current. A voltage applied to the gate causes current to flow between the drain and source pins. Figure 17 shows a simplified explanation of how a MOSFET works. A voltage is applied to the gate pin in order to control the flow of current between the drain and source pins. When the voltage between the gate and source pins (VGS) is below a certain limit, called the threshold voltage (Vth), no current flows. When VGS exceeds Vth, the MOSFET begins to conduct, allowing current to pass through. This is what allows you to use the gate voltage of a MOSFET to turn a DC motor on and off. For this robot, the MOSFET's gate voltage is controlled by the IR sensor.
how a MOSFET works
Figure 17. Simplified explanation of a MOSFET's operation.

The exact description of how a MOSFET works is more complicated than this. As VGS increases past Vth, the current through the MOSFET will continue to increase. Eventually the MOSFET will reach saturation, where no additional current can flow, even if VGS continues to increase. The MOSFET's behavior will also depend on the type of load to which it is attached. The MOSFET used in this project is an N-channel MOSFET, which requires a positive gate voltage to turn on. A P-channel MOSFET requires a negative gate voltage to turn on. Advanced users can refer to the Bibliography for more information on MOSFETs.

Q: How does the circuit work? What is the circuit diagram?
A: Figure 18 shows the complete circuit diagram for the robot. More detailed explanations for some of these individual components are given in the questions above. Refer to Table 5 for a list of the individual circuit diagram symbols, if necessary.

Since the circuit consists of two identical halves—one to control each motor—we can just explain how one half of the circuit works. The same explanation applies to the other side.

  • The batteries supply a voltage, Vbatt to the circuit. When the switch is closed, V1 = Vbatt. When the switch is open, V1 is "floating", so the circuit does not receive any power.
  • The 220 Ω resistor acts as a current-limiting resistor for the IR LED. It prevents too much current from flowing through the LED and burning it out.
  • The IR LED emits infrared light. If enough light is reflected back to the sensor, it triggers the base of the phototransistor, allowing current to flow from the collector to the emitter.
  • The 4.7 kΩ resistor acts as a pull-down resistor. When the phototransistor is not conducting, it "pulls down" the MOSFET's gate voltage (labeled V2 in Figure 18) to ground. When the phototransistor conducts, V2 will increase, approaching, but not quite reaching, Vbatt.
  • When V2 is below the MOSFET's threshold voltage Vth, no current flows through the motor. When V2 exceeds the threshold voltage, the MOSFET allows current to flow, turning the motor on.
  • The end result is that when the IR sensor "sees" white, it triggers the MOSFET and turns the motor on. When it "sees" black, it turns the motor off.
  • Finally, each motor has a diode connected across its terminals. Motors can create large voltage spikes when they abruptly come to a stop (this has to do with the relationship between electrical current and magnetic fields, if you want to do more research on the explanation). The diodes help prevent damage to the MOSFET by safely discharging the current generated by the voltage spike.
circuit diagram for line following robot
Figure 18. A complete circuit diagram for the line-following robot.
Q: What are the circuit diagram symbols for the components in this project?
A: Table 5 shows a picture, breadboard diagram symbol, and circuit diagram symbol (when applicable) for each component in the project.

Item NamePicture Breadboard Diagram Symbol Circuit Diagram Symbol
Battery pack
4xAA battery holder
battery holder symbol
battery circuit diagram symbol
Breadboard
breadboard picture
breadboard diagram symbol of a breadboard
N/A
Switch
SPDT switch
switch symbol
spdt switch circuit diagram symbol
Jumper wire
jumper wires
jumper wire symbol
jumper wire circuit diagram symbol
DC Motor
DC motor
motor symbol
DC motor breadboard symbol
MOSFET
MOSFET
mosfet breadboard symbol
mosfet breadboard symbol
Diode
diode
diode breadboard symbol
diode breadboard symbol
4.7k Ω resistor
4.7 k resistor picture
4.7k resistor symbol
resistor circuit symbol
220 Ω resistor
220 resistor picture
220 resistor breadboard symbol
resistor circuit symbol
IR Sensor
IR emitter detector
IR sensor breadboard symbol
IR emitter detector circuit diagram symbol
Table 5. A picture, a breadboard diagram symbol, and a circuit diagram symbol for each of the components used in this project.
Q: How did you make the breadboard diagrams for this project?
A: The breadboard diagrams for this project were created using Inkscape, a free vector graphics program. You can find free scalable vector graphic (SVG) files for many circuit components on Wikimedia Commons. There are other free programs specifically for making breadboard diagrams, such as Fritzing.

Ask an Expert

The Ask an Expert Forum is intended to be a place where students can go to find answers to science questions that they have been unable to find using other resources. If you have specific questions about your science fair project or science fair, our team of volunteer scientists can help. Our Experts won't do the work for you, but they will make suggestions, offer guidance, and help you troubleshoot.

Ask an Expert

Contact Us

If you have purchased a kit for this project from Science Buddies, we are pleased to answer any question not addressed by the FAQ above.

In your email, please follow these instructions:
  1. What is your Science Buddies kit order number?
  2. Please describe how you need help as thoroughly as possible:

    Examples

    Good Question I'm trying to do Experimental Procedure step #5, "Scrape the insulation from the wire. . ." How do I know when I've scraped enough?
    Good Question I'm at Experimental Procedure step #7, "Move the magnet back and forth . . ." and the LED is not lighting up.
    Bad Question I don't understand the instructions. Help!
    Good Question I am purchasing my materials. Can I substitute a 1N34 diode for the 1N25 diode called for in the material list?
    Bad Question Can I use a different part?

Contact Us

Related Links

News Feed on This Topic

 
, ,
Note: A computerized matching algorithm suggests the above articles. It's not as smart as you are, and it may occasionally give humorous, ridiculous, or even annoying results! Learn more about the News Feed

Looking for more science fun?

Try one of our science activities for quick, anytime science explorations. The perfect thing to liven up a rainy day, school vacation, or moment of boredom.

Find an Activity