Break beam sensor

This invention demonstrates how to connect a break beam sensor to your ThinkerShield. A break beam sensor can tell when something disrupts an infrared beam. One side acts as a sender and the other is a receiver of the signal. When the infrared beam is broken you may hear a sound or a light may be activated. For example, break beams are commonly used to let a shopkeeper know when someone enter the store by emitting a beep or chime. In this invention the light will turn on if the infrared beam is broken.

Step 1

Step 1

Connect first alligator clip to GND (ground) on your ThinkerShield and to the negative (black) wire of your sending breakbeam sensor (This is the component with only two wires).

Step 2

Step 2

Connect second alligator clip to external pin VCC on your ThinkerShield and to the positive (red) wire of your sending breakbeam sensor (This is the component with only two wires).

Step 3

Step 3

Connect third alligator clip to external pin VCC on your ThinkerShield and to the positive (red) wire of your receiving breakbeam sensor (This is the component with three wires).

Step 4

Step 4

Connect fourth alligator clip to GND (ground) on your ThinkerShield and to the negative (black) wire of your receiving breakbeam sensor (This is the component with three wires).

Step 5

Step 5

Connect fifth alligator clip to external pin D2 on your ThinkerShield and to the signal sensor (white) wire of your receiving breakbeam sensor (This is the component with three wires).

Step 6

// declare sensor and LED variables
int sensor = 2;
int led = 8;

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

//setup the led as an output)
 pinMode (led, OUTPUT);
}

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

Add a comment