I have a problem using node.js to program the RaspberryPi GPIO. I am using the onoff library. This is my code:
var Gpio = require('onoff').Gpio, led = new Gpio(20, 'out'), button = new Gpio(18, 'in', 'both'); button.watch(function (err, value) { if (err) { throw err; } led.writeSync(value); }); function exit() { button.unexport(); } process.on('SIGINT', exit);
The problem is that the attached button never starts. When I use Python to read the value of a button, it works. I have already tried other node.js libraries like rpi-gpio, pi-gpio and wiring-pi. None of them worked for me. I am using Raspberry PI B + with the latest Raspbian installed. Any ideas?
source share