Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const b = require('bonescript');
- const led = "P8_13";
- b.pinMode(led, 'out');
- b.pinMode('P8_19', b.INPUT);
- setInterval(checkPIR, 5000); // Check this Sensor Every 5 Seconds
- function checkPIR(){
- b.digitalRead('P8_19', printStatus);
- }
- function printStatus(err, x){
- if(err === 1){
- b.digitalWrite(led, 0);
- console.log("No Motion Yet!");
- }
- else{
- (x.value === 0);
- b.digitalWrite(led, 1);
- console.log("Motion Detected!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement