Last active
August 23, 2016 09:41
-
-
Save dynamis/0a471119b5526164cf618be6df710a1a to your computer and use it in GitHub Desktop.
人感センサー利用サンプル for CHIRIMEN
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.addEventListener('DOMContentLoaded', function () { | |
let{ spawn, sleep } = task; | |
spawn(function () { | |
const gpio = yieldnavigator.requestGPIOAccess(); | |
const sensor = gpio.ports.get(196); // Motion Sensor Data Pin: CN1 7 | |
const led = gpio.ports.get(198); // LED Anode Pin: CN1 9 | |
yield sensor.export('in'); | |
yield led.export('out'); | |
while (true) { | |
sensor.onchange = v => { | |
console.info(v); | |
led.write(v); | |
}; | |
yield sleep(1000); | |
} | |
}); | |
}, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment