Chapter 7 - Navigating with Infrared Headlights

The BOE Shield-Bot can already use whiskers to get around, but it only detects obstacles when it bumps into them. Wouldn’t it be convenient if the BOE Shield-Bot could just “see” objects and then decide what to do about them? Well, that’s what it can do with infrared headlights in this chapter. Each headlight is an infrared LED inside a tube that directs the light forward, just like a flashlight. Each eye is an infrared receiver that sends the Arduino high/low signals to indicate whether it detects the infrared LED’s light reflected off an object.  You will program the robot and create an IR detection circuit for object detection and avoidance. The result will be autonomous navigation.


By the time you complete this section you will be able to:32335

  1. Understand what an infrared sensor is and how it is used.
  2. Explain what IR light is and why you can’t see it. 
  3. Build and Mount IR headlights on the robot 
  4. Build an IR Object Detection Circuit with IR LEDs for the robot
  5. Test the IR receivers and understand how the program communicates with the IR circuit. 
  6. Test the IR object detector and debug any issues that arise 
  7. Program the robot to use the IR detection circuit for object detection 
  8. Program the robot for infrared interference 
  9. Modify the Object Detection Circuit to adjust the range detection of the IR sensor 
  10. Program the robot to use the IR detection circuit for object avoidance 
  11. Program the robot to stop moving when a drop off is detected – to detect edges of a table 


  1. View the videos and items in the Overview section below.
  2. Open the worksheet document and review the questions. 
  3. Read and follow the instructions in Robotics with the BOE Shield-Bot for Arduino Chapter 7.
  4. Download Chapter 7 Arduino Code.
  5. Complete the BOE Shield-Bot activities assigned by your instructor, following the step-by-step tutorials and videos in the Activities section below. If self-study, do all the "Your Turn" parts for each activity in the chapter. (Note: It is only by typing in the commands that you truly begin to understand programming. So don't short change yourself.)
  6. Review the Key Points or FAQs below.
  7. Answer the questions in the worksheet document.
  8. Complete the Programming Exercises at the end of the chapter and fill out the worksheet for them.
  9. Complete the Projects at the end of the chapter and fill out the worksheet for them.
  10. Check your answers. When complete, turn in the Worksheet Doc to your instructor (print, email or other method defined by your instructor). Self-study students can optionally send to a parent, mentor or friend.


Activity 1: Build and Test the Object Detectors

Activity 2: Field Testing

Activty 3: Detection Range Adjustments

Activity 4: Object Detection and Avoidance

Activity 5: High-performance IR Navigation

Activity 6: Drop-off Detector


Additional Resources

Arduino Coding Reference (Help for Arduino Code)

Key Points or FAQs:


What does a high signal and a low signal mean from the IR detector?

The high signal means that there are no objects within the range of the IR detector. The lower the number returned in the signal, the closer an object is to the IR detector.

Advanced topic: Learn more about IR Detectors

What is an interference sniffer and why is it needed?

An interference sniffer is a routine that checks to see if a value returned is valid or possibly bad data outside of what is expected. It's needed to make sure the robot doesn't respond to false positives or data that is outside of the expected results. For Example, if IR is detected in an area where the robot is not sending IR, then it could lead to false results. By using an interference sniffer, the robot can check to make sure the area in which it will be operating is free of bad data or stray signals.

 How do I know which resistor is the best one to use with  the IR LEDs?

Through trial and error, you can experiment with changing the resistor in the circuit from the 220 Ohm to the 470 Ohm, then try the 1 K Ohm, then the 4.7 K Ohm. Remember to disconnect power and the programming cable before you make changes to a circuit. Remember also that the same sketch will run again when you reconnect power, so you can pick up right where you left off with each test.  When you change the circuit, the one that produces the brightest value for the Red LED will probably produce the best results for the IR LED, meaning it will be able to detect objects further away.

How do I know when an object is detected with the IR LEDs?

Just like the whiskers, when no object is detected, the output is high (1) ; when an object is detected, the output is low (0). So we are looking for a 0 value to indicate an object is detected.

What if the robot doesn't detect an object? Is the IR LED broken?

While it is possible to have a faulty IR LED, it is not the most likely cause of the problem. Check your circuit and make sure no wires are touching each other. Check to make sure you have charged batteries.  Review your code and download it again. Check the area where you are trying the circuit. Is there interference from light sources or other IR devices? 


OLD Videos (These are currently Boe-Bot NOT Boe Shield)

Copyright 2016 Interactive Media Publishing, All rights reserved