Advertisement
silver2row

BoneScript and PIR Sensor

Jun 30th, 2019
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const b = require('bonescript');
  2. const 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(err, x){
  14.     if(err === 1){
  15.         b.digitalWrite(led, 0);
  16.     console.log("No Motion Yet!");
  17.     }
  18.     else{
  19.         (x.value === 0);
  20.         b.digitalWrite(led, 1);
  21.     console.log("Motion Detected!");
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement