Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var b = require('bonescript');
- var 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(x, err){
- if(x === 0){
- b.digitalWrite(led, 1);
- console.log("Motion!");
- }
- else{
- (err === 1);
- b.digitalWrite(led, 0);
- console.log("No Motion Detected!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement