Advertisement
silver2row

bonescript and change this when I can...

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