Advertisement
silver2row

BoneScript and the PIR Again...

Jun 30th, 2019
252
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, 5000); // Check this Sensor Every 5 Seconds
  8.  
  9. function checkPIR(){
  10. b.digitalRead('P8_19', printStatus);
  11. }
  12.  
  13. function printStatus(x, err){
  14.     if(x === 0){
  15.         b.digitalWrite(led, 1);
  16.     console.log("Motion!");
  17.     }
  18.     else{
  19.         (err === 1);
  20.         b.digitalWrite(led, 0);
  21.     console.log("No Motion Detected!");
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement