WiringPi / WiringPi-Node

Node.js bindings to wiringPi
333 stars 94 forks source link

Software debounce? #93

Open michaeljanich opened 6 years ago

michaeljanich commented 6 years ago

I use wpi.wiringPiISR(this.switchpin, wpi.INT_EDGE_RISING, this.toggle.bind(this)); to connect to a switch button and toggle a light.

But I get bounce. Usually I [Arduino] software-debounce with

if (digitalRead(pin)) {
     delay(25);
     if (digitalRead(pin)) {
         toggle();
     }
}

How is that best done on node? with wpi.delay(25)? or setTimeout(function() {}, 25);?

THANKS