Arduino - IR Beam test
Channel: Aaron Hastings
Date: 27/08/2011

This is a very basic test of a Velleman PMK120R/T IR Light Barrier interfacing with an Arduino microcontroller. The IR beam is between the clear photo transistor on the left and the two blue (IR) LEDs on the right. Breaking this beam sends a signal to the Arduino through the white wires, enabling the Arduino to respond accordingly. In this case, it simply illuminates the red LED on the breadboard.

Normally there exists a buzzer where the white wires are. But buzzers aren't nearly as fun as hooking up to an Arduino. 

This was filmed in 091 Labs makerspace in Galway, Ireland.

The Arduino code I used for this is below:

int inputPin = 6;
int ledPin = 10;

void setup()
{
  pinMode(inputPin, INPUT);
  pinMode(ledPin, OUTPUT);
}

void loop()
{
  if (digitalRead(inputPin) == HIGH)
  {
    digitalWrite(ledPin, HIGH);
  }
  if (digitalRead(inputPin) == LOW)
  {
    digitalWrite(ledPin, LOW);
  }
}