Created
May 9, 2015 09:19
-
-
Save Rebolon/099c959d467e9e05adff to your computer and use it in GitHub Desktop.
BeagleBoard + PIR Motion Sensor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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