Skip to content
Parallax Learn (Stage)

Parallax Learn (Stage)

This is the staging site. Please see https://learn.parallax.com for the official site.

  • Welcome
  • Tutorials
        • Tutorial Series head tag

          Tutorial Series
        • Tutorial Series

          The special, classroom-ready series pages are organized collections of tutorials for our most popular hardware and/or languages. The tutorials for each topic are conveniently accessible from a single page, shown in the order it is recommended that they be completed.
        • Robotics Series Head tag

          Robotics Series
        • Robotics Series

          • Artificial Intelligence Tutorial Series
          • Cybersecurity: Radio Data tutorialCybersecurity Tutorial Series
          • cyber:bot Tutorial Series
          • Boe-Bot Tutorial SeriesBoe-Bot Tutorial Series
          • Arduino Shield-Bot Tutorial Series
          • ActivityBot with C TutorialsActivityBot with C Tutorials
          • ActivityBot with BlocklyProp Tutorial SeriesActivityBot with BlocklyProp Tutorial Series
          • Scribbler 3 Tutorial SeriesScribbler 3 Tutorial Series
        • Electronics & Programming Series Head tag

          Electronics & Programming Series
          • BS2 Board of Education Tutorial SeriesBS2 Board of Education Tutorial Series
          • Propeller C-Language BasicsPropeller C Basics and Projects
          • FLiP Try-It Kit C Tutorial SeriesFLiP Try-It Kit C Tutorial Series
          • FLiP Try-It Kit BlocklyProp TutorialsFLiP Try-It Kit BlocklyProp Tutorials
          • Badge WX Tutorial SeriesBadge WX Tutorial Series
          • Propeller BlocklyProp Basics and ProjectsPropeller BlocklyProp Basics and Projects
          • View All Tutorial Series »
        • Browse Tutorials
        • Browse Tutorials

          Individual tutorials sorted by robot or kit, and language.
        • By Robot or Kit
          • ActivityBot
          • SumoBot WX
          • Boe-Bot
          • Shield-Bot
          • cyber:bot
          • Badge WX
          • ELEV-8
          • ARLO
        • By Language
        • By Language

          • Propeller C
          • Arduino
          • BlocklyProp
          • PBASIC
          • Python
          • View All Tutorials »
  • Educators
  • Reference
  • Downloads
  • Home
  • All Courses
  • Robotics with the Board of Education Shield for Arduino

Robotics with the Board of Education Shield for Arduino

Sniffing for IR Interference

Sniffing for IR Interference

You might have found that your BOE Shield-Bot said it detected something even though nothing was in range.  That may mean a nearby light is generating some IR light at a frequency close to 38.5 kHz.  It might also mean that direct sunlight streaming through a window is causing false detections.  If you try to have a BOE Shield-Bot contest or demonstration near one of these light sources, your infrared systems could end up performing very poorly!  So, before any public demo, make sure to check the prospective navigation area with this IR interference “sniffer” sketch ahead of time.

The concept behind this sketch is simple: don’t transmit any IR through the IR LEDs, just monitor to see if any IR is detected.  If IR is detected, sound the alarm using the piezospeaker.

You can use a handheld remote for just about any piece of equipment to generate IR interference. 
TVs, VCRs, CD/DVD players, and projectors all use the same type of IR detectors you have on your BOE Shield-Bot right now.  So, the remotes you use to control these devices all use the same kind of IR LED that’s on your BOE Shield-Bot to transmit messages to your TV, VCR, CD/DVD player, etc. All you’ll have to do to generate IR interference is point the remote at your BOE Shield-Bot and repeatedly press/release one of the remote’s buttons.

Example Sketch – IrInterferenceSniffer

With this sketch, your BOE Shield-Bot should play a tone, turn on its indicator LEDs, and display a warning in the Serial Monitor any time it detects infrared.  Again, since it’s not transmitting any IR, it means the 38 kHz infrared has to be coming from an outside source.

  • Enter, save, and upload IrInterferenceSniffer to your Arduino.
  • Test to make sure the BOE Shield-Bot sounds the alarm when it detects IR interference.  If you are in a classroom, you can do this with a separate BOE Shield-Bot that’s running TestBothIrAndIndicators.  Just point its IR LEDs into the IrInterferenceSniffer bot’s IR receivers.  If you don’t have a second BOE Shield-Bot, just use a handheld remote for a TV, VCR, CD/DVD player, or projector.  Simply point the remote at the BOE Shield-Bot and repeatedly press and release one of its buttons.  If the BOE Shield-Bot responds by sounding the alarm, you know your IR interference sniffer is working.
/*
 * Robotics with the BOE Shield - IrInterferenceSniffer
 * Test for external sources of infrared interference.  If IR interference is
 * detected: Serial Monitor displays warning, piezospeaker plays alarm, and
 * indicator lights flash.
 */

void setup()                                 // Built-in initialization block
{
  tone(4, 3000, 1000);                       // Play tone for 1 second
  delay(1000);                               // Delay to finish tone

  pinMode(10, INPUT);                        // Left IR Receiver
  pinMode(3, INPUT);                         // Right IR Receiver
  pinMode(8, OUTPUT);                        // Left indicator LED
  pinMode(7, OUTPUT);                        // Right indicator LED

  Serial.begin(9600);                        // Set data rate to 9600 bps
}  
 
void loop()                                  // Main loop auto-repeats
{
  int irLeft = digitalRead(10);              // Check for IR on left
  int irRight = digitalRead(3);              // Check for IR on right
 
  if((irLeft == 0) || (irRight == 0))        // If left OR right detects
  {                                         
    Serial.println("IR interference!!!");    // Display warning
    for(int i = 0; i < 5; i++)               // Repeat 5 times
    {
      digitalWrite(7, HIGH);                 // Turn indicator LEDs on
      digitalWrite(8, HIGH);
      tone(4, 4000, 10);                     // Sound alarm tone
      delay(20);                             // 10 ms tone, 10 between tones
      digitalWrite(7, LOW);                  // Turn indicator LEDs off
      digitalWrite(8, LOW);
    }
  }  
}

Your Turn – Testing for Fluorescent Lights that Interfere

  • Disconnect your BOE Shield-Bot from its programming cable, and point it at any fluorescent light near where you plan to operate it. 
  • Especially if you get frequent alarms, turn off that fluorescent light before trying to use IR object detection under it.
  • If the source turns out to be sunlight streaming in through a window, close the blinds and retest, or move your obstacle course to a location that’s well away from the window.

Always use this IrInterferenceSniffer to make sure that any area where you are using the BOE Shield-Bot is free of infrared interference.


Printer-friendly version
Activity 2: Field Testing
Prev
Activty 3: Detection Range Adjustments
Next

DISCUSSION FORUMS | PARALLAX INC. STORE

About | Terms of Use | Feedback: learn@parallax.com | Copyright©Parallax Inc. 2024

© 2025 Parallax Learn (Stage) • Built with GeneratePress