Advertisement
CharlesJGantt

BBB LED

Oct 1st, 2014
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. var b = require('bonescript');
  2. var led = "P8_13";
  3. b.pinMode(led, 'out');
  4. b.pinMode('P8_19', b.INPUT);
  5. setInterval(checkPIR, 2500); // Checks the Sensor Every 2.5 Seconds
  6.  
  7. function checkPIR(){
  8. b.digitalRead('P8_19', printStatus);
  9. }
  10.  
  11. function printStatus(x) {
  12. if(x.value === 0){
  13. b.digitalWrite(led, 1);
  14. console.log("Motion Detected");
  15. }
  16. else{
  17. console.log("No Motion Detected");
  18. b.digitalWrite(led, 0);
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement