initial
This commit is contained in:
19
node_modules/onoff/examples/light-switch.js
generated
vendored
Normal file
19
node_modules/onoff/examples/light-switch.js
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
|
||||
const Gpio = require('../onoff').Gpio;
|
||||
const led = new Gpio(17, 'out');
|
||||
const button = new Gpio(4, 'in', 'both');
|
||||
|
||||
button.watch(function (err, value) {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
led.writeSync(value);
|
||||
});
|
||||
|
||||
process.on('SIGINT', function () {
|
||||
led.unexport();
|
||||
button.unexport();
|
||||
});
|
||||
|
Reference in New Issue
Block a user