I am new to this Forum so I hope that I am in the right place.
I have the following idea:
I want to connect two buttons to my Raspberry Pi 3 and trigger functions on my Node.js Sever when pressed.
Code: Select all
var Gpio = require('onoff').Gpio; //include onoff to interact with the GPIO
var pushButton = new Gpio(17, 'in', 'rising', {debounceTimeout: 10});
var pushButton2 = new Gpio(18, 'in', 'rising', {debounceTimeout: 10});
pushButton.watch(function (err, value) {
//Watch for hardware interrupts on pushButton GPIO, specify callback function
if (err) { //if an error
console.error('There was an error', err); //output error message to console
return;
console.log("Btn1");
});
pushButton2.watch(function (err, value) {
//Watch for hardware interrupts on pushButton GPIO, specify callback function
if (err) { //if an error
console.error('There was an error', err); //output error message to console
return;
}
console.log("Btn2");
});
Now the Issue I am running into is, that whenever I press Button1 the Button2 is pressed as well and if i try to press Button2 it is not working 100% of the time, meaning if i press it around 5 times it registers one event.
Anyone any ideas?