Files
PiAlive/node_modules/onoff/examples/light-switch.js
2018-05-16 10:10:23 +02:00

20 lines
308 B
JavaScript

"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();
});