Intel Edison I.R. Break Beam Sensor

Introduction: Intel Edison I.R. Break Beam Sensor

About: lost my arm at 18, now I'm hacking stuff for disabled people (or animals)

Intel Edison Arduino I.R. Break Beam Sensor

Step 1: Parts

Intel Edison Arduino https://www.adafruit.com/products/2180

I.R. sensor https://www.adafruit.com/products/157

I.R. L.E.D. https://www.adafruit.com/products/387

I used the I.R. break beam sensor ( https://www.adafruit.com/products/2168), but you can recycle any broken device that uses an I.R. remote, as long as the I.R. L.E.D. and sensor aren't what's broken.

Step 2: Assembly

Wire it up like the picture above. You can add an external L.E.D. , I recommend pin 12, it wouldn't blink an external on pin 13, for me, but the on board L.E.D. did.

Step 3: Download the Code Below

/*

IR Breakbeam sensor demo!

*/

#define LEDPIN 12

// Pin 13: Arduino has an LED connected on pin 13

// Pin 11: Teensy 2.0 has the LED on pin 11

// Pin 6: Teensy++ 2.0 has the LED on pin 6

// Pin 13: Teensy 3.0 has the LED on pin 13

#define SENSORPIN 4

// variables will change:

int sensorState = 0, lastState=0;

// variable for reading the pushbutton status

void setup()

{

pinMode(LEDPIN, OUTPUT); // initialize the LED pin as an output:

pinMode(SENSORPIN, INPUT); // initialize the sensor pin as an input:

digitalWrite(SENSORPIN, HIGH); // turn on the pullup

Serial.begin(9600);

}

void loop()

{

// read the state of the pushbutton value:

sensorState = digitalRead(SENSORPIN);

// check if the sensor beam is broken

// if it is, the sensorState is LOW:

if (sensorState == LOW) {

digitalWrite(LEDPIN, HIGH); // turn LED on:

}

else {

digitalWrite(LEDPIN, LOW); // turn LED off:

}

if (sensorState && !lastState) {

Serial.println("Unbroken");

}

if (!sensorState && lastState) {

Serial.println("Broken");

}

lastState = sensorState;

}

Be the First to Share

    Recommendations

    • Puzzles Challenge

      Puzzles Challenge
    • Rice & Grains Challenge

      Rice & Grains Challenge
    • CNC and 3D Printing Contest

      CNC and 3D Printing Contest

    2 Comments

    0
    pfranks6130
    pfranks6130

    Question 4 weeks ago on Introduction

    Good morning. I need to add both vertical and horizonal beams to build a grid for a strike zone. I'm part of a crew training baseball/softball umpire for youth sports. During plate umpire training, we use a pitching machine to deliver the pitch and the ball would have to break both the horizontal and veritcal lasers to be a strike. If it only broke only the vertical or horizonal beams, it would be out of the zone and be ruled a ball. Can you advise me on how to develop the process on this? I have a picture of a frame built showing the laser layout, if it would help you understand what I'm referring to. Thanks.

    0
    MarioB5
    MarioB5

    7 years ago

    do you know if it works with objects?