rpio2
Version:
Control Raspberry Pi GPIO pins with node.js. Fast and easy to use.
20 lines (15 loc) • 361 B
JavaScript
const Gpio = require('../lib/index.js').Gpio;
const button = new Gpio(32);
const output = new Gpio(40);
button.open(Gpio.INPUT);
output.open(Gpio.OUTPUT, Gpio.LOW);
//button down
button.on('rising', function(obj){
output.toggle();
});
process.on("SIGINT", function(){
button.close();
output.close();
console.log('shutdown!');
process.exit(0);
});