Categories
TUTORIALS

How to Use an Infrared Break Beam Sensor to Trigger Sound

This tutorial will focus on how to use a break beam sensor to trigger sound from a passive buzzer. This is part of a larger project called Digital Playground that will use lights and sound to add an interactive digital layer to playgrounds for kids. 

Parts List:

Sensor Specifications:

Infrared (IR) break-beam sensors are a simple way to detect motion. They work by having a transmitter side that sends out a beam of IR light that can not be detected by the naked eye to a receiver across the way which is sensitive to that same light. When something passes between the two, the IR sensor can detect this disruption in the signal. Once the infrared beam is broken, the receiver will detect this disruption and alert the user that the beam has been broken. Without any other outputs attached to the circuit, the IR sensor can print to serial monitor that motion has been detected; however, when attached to another output such as an LED or buzzer, this can be used to signal if the beam has been broken.

Circuit Diagram:

Connections Set Up:

Active Buzzer:

  • Connect the positive pin to any Arduino PWM pin (we will use pin 7)
  • Connect the negative pin to GND

IR Break Beam Sensor:

  • Transmitter (two wire connections)-
  • Receiver (three wire connections)-

Steps: 

  1. Collect your parts 
  2. Wire up the buzzer by connecting the positive pin to 7 on your Arduino Uno and the negative pin to GND on the Arduino board 
  3. Wire up the IR Break Beam sensor starting with the transmitter. Connect the red wire to positive and the black wire to negative 
  4. Wire up the IR Break Beam receiver. Connect the red wire to positive and the black wire to negative. Then connect the white wire to column D row 48 
  5. Connect a Male to Male jumper wire from the positive column on your breadboard to 5V on your Arduino UNO
  6. Connect a Male to Male jumper wire from the negative column on your breadboard to GND on your Arduino UNO 
  7. Connect a Male to Male jumper wire from column A row 48 on your breadboard to pin 7 on your Arduino UNO 
  8. Plug in your Arduino UNO to the power supply
  9. Now run this code on ArduinoIDE
//declare sensor and buzzer variables
int sensor = 2;
int buzzer = 7; 

void setup() {
  // setup the sensor as an input
  pinMode (sensor, INPUT);
  //write HIGH to sensor to get it started
  digitalWrite (sensor, HIGH);
  //setup the buzzer as an output
  pinMode (buzzer, OUTPUT);
}

void loop() {
  // check if the beam has been broken (read LOW)
  if (digitalRead (sensor) == LOW)
  {  
    // turn on buzzer
  digitalWrite (buzzer, HIGH);
  }
  // else if the beam is unbroken (read HIGH)
  else
  {
  //  turn off buzzer 
  digitalWrite (buzzer, LOW);
  }
}

10. Now use your finger to break the beam between the transmitter and receiver

11. Here’s how it should work:

12. Comment for questions or further explanation

References:

Leave a Reply

Your email address will not be published. Required fields are marked *