-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Button debouncing #27
Comments
Hey @8power8, thanks. The constructor has an option called debounceTimeout. Here is an example of it's usage which works for me: var Gpio = require('onoff').Gpio,
button = new Gpio(4, 'in', 'falling', {
debounceTimeout : 50
}),
count = 0;
button.watch(function(err, value) {
if (err) throw err;
count += 1;
console.log('button released ' + count + ' times');
if (count === 500) {
button.unexport();
}
}); The circuit is similar to this one here, except that the button is wired to GPIO4 rather that GPIO17. Note that the 10KΩ resistor is actually quite important. If it's not there, small movements of the button or the wire connecting the button to GPIO4 can result in tens of unauthentic interrupts. |
Hmm, if you're using the BeagleBone Black, you could give this Button a try. Internally it uses the Linux gpio-keys driver for detecting button events. The gpio-keys driver also supports software debouncing. |
It works like a charm. |
That's nice to hear. I guess the issue can be closed. |
Hi there,
Nice GPIO library !
Is there any internal mechanism for debouncing the hardware interrupts watch() function? I am having issues with this, and found nothing to get rid of it.
The text was updated successfully, but these errors were encountered: