Jump to main content

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

1
2
3
4
5
163 reviews

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!

Summary

Areas of Science
Difficulty
 
Time Required
Short (2-5 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 for Electronics and Circuits if you have not used a breadboard before.
Material Availability
A kit is available from our partner Home Science Tools. See the Materials section for details.
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.
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.

Objective

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

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 this video shows a demonstration of how it works.

Photo of a robot designed to follow lines
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.

Diagram of an infrared light sensor that can detect light bounced off of bright surfaces but not dark surfaces

A sensor for the line-following robot consists of an infrared emitter and an infrared detector. When the IR emitter shines a light on a bright surface the reflection is bounced into the IR detector. When the IR emitter shines a light on a dark surface, the IR light is absorbed and doesn't reflect any light towards the IR detector. When the IR detector doesn't detect any IR light then the sensor knows it is no longer on a dark surface.


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!

Diagram of a line-following robot using light sensors to turn or remain on a straight path

Two infrared sensors are placed on the front of a line-following robot chassis and spaced apart slightly wider than the width of a black marker line. As the two sensors scan either side of a black line the light will be reflected off the white surface and the sensors will send power to the motors left and right wheels. When a line begins to curve left, the left IR sensor will detect the dark surface and cut power to the left wheels which cause the robot to begin turning towards the left. When the robot is turned far enough left that the sensor is no longer over the black line, than the left motor will receive power to turn again. The same situations applies for a lien curving right and the right IR sensor and motor.


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
A battery pack that can hold four double A batteries
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
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
A switch with three leads
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
Six jumper wires of different lengths
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
A direct current 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 metal-oxide-semiconductor field-effect transistor or 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
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
Four male to 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
A 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
An infrared 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).

Two flow charts describe the relationship between an IR sensor, MOSFET and motor

When an infrared sensor goes over a black surface the IR detector won't detect an IR reflection and only low voltage power is sent to the MOSFET. If the MOSFET doesn't receive enough power, current stops flowing to the motor and the motor stops. When an IR sensor goes over a white surface the IR light from the emitter is reflected off the surface and is detected by the IR detector which then sends high voltage to the MOSFET. The MOSFET is able to pass a current to the motor and the motor will turn the wheels of the robot.


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:

Circuit components:

Advanced terms (see Help section)

Questions

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:

Materials and Equipment Buy Kit

Recommended Project Supplies

Get the right supplies — selected and tested to work with this project.

View Kit

Disclaimer: Science Buddies participates in affiliate programs with Home Science Tools, Amazon.com, Carolina Biological, and Jameco Electronics. Proceeds from the affiliate programs help support Science Buddies, a 501(c)(3) public charity, and keep our resources free for everyone. Our top priority is student learning. If you have any comments (positive or negative) related to purchases you've made for science projects from recommendations on our site, please let us know. Write to us at scibuddy@sciencebuddies.org.

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.

An assembled chassis with a breadboard and battery pack for a line-following robot
Figure 5. A completed BlueBot chassis with breadboard and battery pack on top.

Assembling Your Circuit

If you purchased your kit before December 2, 2019, use these instructions to complete your assembly.
  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 for Electronics and Circuits.
  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
A switch with three leads
Circuit diagram symbol for a switch
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
A purple jumper wire
Circuit diagram symbol for a jumper wire
J2 to (+) bus Color does not matter.
Jumper wire
A purple jumper wire
Circuit diagram symbol for a jumper wire
Left side (+) bus to right side (+) bus Color does not matter.
Jumper wire A purple jumper wire Circuit diagram symbol for a jumper wire Left side (-) bus to right side (-) bus Color does not matter.
MOSFET 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 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 A purple jumper wire Circuit diagram symbol for a jumper wire A13 to (-) bus Color does not matter.
Jumper wire A purple jumper wire Circuit diagram symbol for a jumper wire A20 to (-) bus Color does not matter.
Diode A12 to (+) bus Gray band must face to the left.
Optional: Shorten the leads.
Diode A19 to (+) bus Gray band must face to the left.
Optional: Shorten the leads.
4.7k Ω resistor A 4.7k ohm resistor Breadboard diagram symbol for a 4.7k ohm resistor A11 to (-) bus Direction does not matter. Make sure you pick the right color bands! (yellow, purple, red, gold)
4.7k Ω resistor A 4.7k ohm resistor Breadboard diagram symbol for a 4.7k ohm resistor A18 to (-) bus Direction does not matter. Make sure you pick the right color bands! (yellow, purple, red, gold)
220 Ω resistor Breadboard diagram symbol for a 220 ohm resistor A5 to (+) bus Direction does not matter. Make sure you pick the right color bands! (red, red, brown, gold)
220 Ω resistor Breadboard diagram symbol for a 220 ohm resistor A25 to (+) bus Direction does not matter. Make sure you pick the right color bands! (red, red, brown, gold)
Top IR sensor An infrared sensor Breadboard diagram for an IR sensor 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 bottom right with pins facing you. Counter-clockwise from the top left, connect blue, black, green, and red wires.
Bottom IR sensor An infrared sensor Breadboard diagram for an IR sensor 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 bottom right with pins facing you. Counter-clockwise from the top left, connect blue, black, green, and red wires.
Top motor Red lead to (+) bus
Black lead to E12
When the robot is driving forward, this is the "right" motor.
Bottom motor Red lead to (+) bus
Black lead to E19
When the robot is driving forward, this is the "left" motor.
Battery holder Red lead to J1
Black lead to (-) bus
Do not insert batteries until circuit is complete.
AA battery 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 with step-by-step instructions viewable online.



A fully wired breadboard for a line-following robot
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.

Popsicle sticks and double side tape are used to mount IR sensors 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 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.
A line-following robot is placed on a white paper with a large black line drawn straight across
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.
A line-following robot is placed on a white paper with a large black line drawn with multiple curves
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.
A line-following robot is placed on a sheet of white paper with a large circle drawn in black ink
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.
Wiring diagram shows how two motors and a battery pack are connected to a breadboard
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.
Wiring diagram shows resistors being replaced on a breadboard
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.
A jumper wire is used to convert a three double A battery pack into a two double A battery pack
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."
Wiring diagram shows resistors being added in parallel on a breadboard
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).

icon scientific method

Ask an Expert

Do you have specific questions about your science project? 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.

Global Connections

The United Nations Sustainable Development Goals (UNSDGs) are a blueprint to achieve a better and more sustainable future for all.

This project explores topics key to Industry, Innovation and Infrastructure: Build resilient infrastructure, promote sustainable industrialization and foster innovation.

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 How to Use an 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?
Photo of a homemade chassis for a line-following robot
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!

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:
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.
Breadboard diagram shows two motors and a battery pack wired to breadboard




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 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.
Simplified diagram of a bipolar transistor allowing current to flow from a collector lead to an emitter lead
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.
A simplified diagram shows electricity moving into a MOSFET through the drain lead and out of the source lead
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 a 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
A battery pack that can hold four double A batteries
Breadboard diagram symbol for a battery pack
Circuit diagram symbol for a battery
Breadboard
A breadboard
Breadboard diagram symbol for a breadboard
N/A
Switch
A switch with three leads
Breadboard diagram symbol for a switch
Circuit diagram symbol for a switch
Jumper wire
Six jumper wires of different lengths
Breadboard diagram symbol for a jumper wire
Circuit diagram symbol for a jumper wire
DC Motor
A direct current motor
Breadboard diagram symbol for a direct current motor
Circuit diagram symbol for a direct current motor
MOSFET
A metal-oxide-semiconductor field-effect transistor or MOSFET
Breadboard diagram symbol for a MOSFET
Circuit diagram symbol for a MOSFET
Diode
A diode
Breadboard diagram symbol for a diode
Circuit diagram symbol for a diode
4.7k Ω resistor
A 4700 ohm resistor
Breadboard diagram symbol for a 4700 ohm resistor
Circuit diagram symbol for a resistor
220 Ω resistor
A 220 ohm resistor
Breadboard diagram symbol for a 220 ohm resistor
Circuit diagram symbol for a resistor
IR Sensor
An infrared sensor
Breadboard diagram symbol for an infrared sensor
Circuit diagram symbol for an infrared sensor
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.

Careers

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

Career Profile
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… Read more
Career Profile
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… Read more
Career Profile
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… Read more
Career Profile
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

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

News Feed on This Topic

 
, ,

Cite This Page

General citation information is provided here. Be sure to check the formatting, including capitalization, for the method you are using and update your citation, as needed.

MLA Style

Science Buddies Staff. "Build a Zippy Line-following Robot (BlueBot Project #3)." Science Buddies, 18 Nov. 2023, https://www.sciencebuddies.org/science-fair-projects/project-ideas/Robotics_p023/robotics/line-following-robot. Accessed 19 Mar. 2024.

APA Style

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


Last edit date: 2023-11-18
Top
We use cookies and those of third party providers to deliver the best possible web experience and to compile statistics.
By continuing and using the site, including the landing page, you agree to our Privacy Policy and Terms of Use.
OK, got it
Free science fair projects.