Reputation: 925
I'm trying to read a simple momentary push button on a Raspberry Pi 5 using NodeJS.
const button = new Gpio(538, 'in', 'both');
button.watch((error, value) => {
console.log(error);
console.log(value);
});
process.on('SIGINT', _ => {
button.unexport();
});
The script runs without errors but whenever I connect pin 26 and GND nothing happens. What's going wrong?
Upvotes: 0
Views: 35
Reputation: 925
Finally succeeded using the node-libgpiod
package
import pkg from 'node-libgpiod';
const { Chip, Line } = pkg;
global.chip = new Chip(4);
global.line = new Line(chip, 2);
line.requestInputMode();
const cycle = () => {
const value = line.getValue();
console.log(value);
};
setInterval(cycle, 50);
Upvotes: 0