This commit is contained in:
2018-05-16 10:10:23 +02:00
commit 79abc63edd
597 changed files with 93351 additions and 0 deletions

29
node_modules/onoff/examples/blink-led-async.js generated vendored Normal file
View File

@ -0,0 +1,29 @@
"use strict";
const Gpio = require('../onoff').Gpio; // Gpio class
const led = new Gpio(17, 'out'); // Export GPIO17 as an output
// Toggle the state of the LED connected to GPIO17 every 200ms 'count' times.
// Here asynchronous methods are used. Synchronous methods are also available.
(function blink(count) {
if (count <= 0) {
return led.unexport();
}
led.read(function (err, value) { // Asynchronous read
if (err) {
throw err;
}
led.write(value ^ 1, function (err) { // Asynchronous write
if (err) {
throw err;
}
});
});
setTimeout(function () {
blink(count - 1);
}, 200);
}(25));