UNPKG

onoff

Version:

GPIO access and interrupt detection with Node.js

20 lines (14 loc) 295 B
'use strict'; const Gpio = require('../onoff').Gpio; const led = new Gpio(17, 'out'); const button = new Gpio(4, 'in', 'both'); button.watch((err, value) => { if (err) { throw err; } led.writeSync(value); }); process.on('SIGINT', _ => { led.unexport(); button.unexport(); });