Beagle Board - beagleboard.org

Demo: PIR Motion Sensor

The PIR Motion Sensor, or Passive Infrared Sensor, is a sensor that takes a snapshot of the room and sets the 'alarm' pin to 'LOW' if it detects changes in heat. Since this sensor is an open collector, it needs a pull-up resistor on the alarm pin, which allows multiple motion sensors to be connected on a single input pin. If motion is detected in this demo, it will output "Motion Detected" on the console and will turn on the LED.

Example

var b = require('bonescript');
var led = "P8_13";
b.pinMode(led, 'out');
b.pinMode('P8_19', b.INPUT);
setInterval(checkPIR, 2500); // Checks the Sensor Every 2.5 Seconds

function checkPIR(){
b.digitalRead('P8_19', printStatus);
}

function printStatus(x) {
    if(x.value === 0){
         b.digitalWrite(led, 1);
    console.log("Motion Detected");
    }
    else{
    console.log("No Motion Detected");
         b.digitalWrite(led, 0);
    }
}




Build and execute instructions

  • Connect the '+' pin from the sensor to 'P9_5' of the BeagleBoard in series with a 10kohm resistor as shown on the right.
  • Connect the '-' pin from the sensor to 'P9_1' of the BeagleBoard.
  • Connect the 'AL' pin from the sensor to 'P8_19' of the BeagleBoard in series with a 10kohm resistor as shown on the right.
  • Connect the LED with a 470ohm resistor as shown on the right
  • Click "Run" on the code. Every 2.5 seconds, the console will tell you if there was motion detected. If there was motion detected, the LED will also turn on.

See also

Related functions

Where to buy

See it in action


Last updated by jessica.lynne.callaway on Thu Dec 19 2013 21:39:31 GMT-0000 (UTC).
2581