Skip to content

Instantly share code, notes, and snippets.

@Rebolon
Created May 9, 2015 09:19
Show Gist options
  • Save Rebolon/099c959d467e9e05adff to your computer and use it in GitHub Desktop.
Save Rebolon/099c959d467e9e05adff to your computer and use it in GitHub Desktop.
BeagleBoard + PIR Motion Sensor
/**
* on J3 & J7 there is no GPIO so don't use it when playing with Digital sensor
*/
var b = require('bonescript'),
led = "USR0",
sensor = "P9_26";
b.pinMode(led, b.OUTPUT);
b.pinMode(sensor, b.INPUT);
setInterval(checkPIR, 1000);
function checkPIR(){
b.digitalRead(sensor, printStatus);
}
function printStatus(x) {
if(x.value === 1){
b.digitalWrite(led, 1);
console.log("MOVING");
} else {
console.log("...");
b.digitalWrite(led, 0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment