Skip to content
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

Getting multiple events when button pressed #26

Closed
ScottChapman opened this issue Jun 30, 2017 · 1 comment
Closed

Getting multiple events when button pressed #26

ScottChapman opened this issue Jun 30, 2017 · 1 comment
Labels

Comments

@ScottChapman
Copy link

I am using a membrane button, one lead to ground, other to GPIO 12. Code below. Problem is that I occasionally get multiple events when I click the button...

var Gpio = require('pigpio').Gpio;
var button1 = new Gpio(12, {
    mode: Gpio.INPUT,
    pullUpDown: Gpio.PUD_UP,
    edge: Gpio.FALLING_EDGE
  });

button1.on('interrupt', function (level) {
        if (level === 0) {
                console.log("Button1 Pressed!");
        }
});
@fivdi
Copy link
Owner

fivdi commented Jul 1, 2017

This is button bounce. There's an article describing the topic here. To resolve the issue with software consider using the lodash debounce function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants