Buttons on separate interrupt pins work fine (triggered on FALLING), bouncing is handling by forcing a 80ms lockout period during which further presses are ignored. I like that solution for being lightweight.
My goal is to have 1 interrupt handle all events (buttons and other digital inputs). I don't want to depend on loop(), I wish to be free to use delay often rather than timer interrupts.
Most buttons execute an action when pressed, some, while pressed.
What I have now (just 2 buttons for now):
schematic
simulate this circuit – Schematic created using CircuitLab
void setup() {
pinMode(17, INPUT_PULLUP);
pinMode(16, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(3), wotHappnd, CHANGE);
}
boolean isDebouncing(){
unsigned int now = millis();
if(now - time_lastPressed > time_debounceLockout){
time_lastPressed = now;
return false;
}
return true;
}
void wotHappnd(){
boolean interruptFalling = digitalRead(3) == LOW;
if(interruptFalling && isDebouncing()) return;
// digitalRead the pins; do stuff
}
Internal pullups on all used pins.
My problem is that often (~4%), on interrupt, the interrupt pin is LOW all button pins are HIGH ("not pressed" - likely bouncing just as I read it). How to fix that?
Can't use delay during an interrupt; delayMicroseconds to wait for stable readout still feels inappropriate; a cap-based delay on the interrupt pin induces a period of floating. Prefer solutions in software or with no more than 1 extra component per input.
[edit] here here's a claim that pin interrupts do some filtering already, which, if true, may make some solutions unreliable.
Buttons on separate interrupt pins work fine (triggered on FALLING), bouncing is handling by forcing a 80ms lockout period during which further presses are ignored. I like that solution for being lightweight.
My goal is to have 1 interrupt handle all events (buttons and other digital inputs). I don't want to depend on loop(), I wish to be free to use delay often rather than timer interrupts.
Most buttons execute an action when pressed, some, while pressed.
What I have now (just 2 buttons for now):
schematic
simulate this circuit – Schematic created using CircuitLab
void setup() {
pinMode(17, INPUT_PULLUP);
pinMode(16, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(3), wotHappnd, CHANGE);
}
boolean isDebouncing(){
unsigned int now = millis();
if(now - time_lastPressed > time_debounceLockout){
time_lastPressed = now;
return false;
}
return true;
}
void wotHappnd(){
boolean interruptFalling = digitalRead(3) == LOW;
if(interruptFalling && isDebouncing()) return;
// digitalRead the pins; do stuff
}
Internal pullups on all used pins.
My problem is that often (~4%), on interrupt, the interrupt pin is LOW all button pins are HIGH ("not pressed" - likely bouncing just as I read it). How to fix that?
Can't use delay during an interrupt; delayMicroseconds to wait for stable readout still feels inappropriate; a cap-based delay on the interrupt pin induces a period of floating. Prefer solutions in software or with no more than 1 extra component per input.
[edit] here's a claim that pin interrupts do some filtering already, which, if true, may make some solutions unreliable.
Buttons on separate interrupt pins work fine (triggered on FALLING), bouncing is handling by forcing a 80ms lockout period during which further presses are ignored. I like that solution for being lightweight.
My goal is to have 1 interrupt handle all events (buttons and other digital inputs). I don't want to depend on loop(), I wish to be free to use delay often rather than timer interrupts.
Most buttons execute an action when pressed, some, while pressed.
What I have now (just 2 buttons for now):
schematic
simulate this circuit – Schematic created using CircuitLab
void setup() {
pinMode(17, INPUT_PULLUP);
pinMode(16, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(3), wotHappnd, CHANGE);
}
boolean isDebouncing(){
unsigned int now = millis();
if(now - time_lastPressed > time_debounceLockout){
time_lastPressed = now;
return false;
}
return true;
}
void wotHappnd(){
boolean interruptFalling = digitalRead(3) == LOW;
if(interruptFalling && isDebouncing()) return;
// digitalRead the pins; do stuff
}
Internal pullups on all used pins.
My problem is that often (~4%), on interrupt, the interrupt pin is LOW all button pins are HIGH ("not pressed" - likely bouncing just as I read it). How to fix that?
Can't use delay during an interrupt; delayMicroseconds to wait for stable readout still feels inappropriate; a cap-based delay on the interrupt pin induces a period of floating. Prefer solutions in software or with no more than 1 extra component per input.
[edit] here's a claim that pin interrupts do some filtering already, which, if true, may make some solutions unreliable.
Buttons on separate interrupt pins work fine (triggered on FALLING), bouncing is handling by forcing a 80ms lockout period during which further presses are ignored. I like that solution for being lightweight.
My goal is to have 1 interrupt handle all events (buttons and other digital inputs). I don't want to depend on loop(), I wish to be free to use delay often rather than timer interrupts.
Most buttons execute an action when pressed, some, while pressed.
What I have now (just 2 buttons for now):
schematic
simulate this circuit – Schematic created using CircuitLab
void setup() {
pinMode(17, INPUT_PULLUP);
pinMode(16, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(3), wotHappnd, CHANGE);
}
boolean isDebouncing(){
unsigned int now = millis();
if(now - time_lastPressed> time_debounceLockout){
time_lastPressed = now;
return false;
}
return true;
}
void wotHappnd(){
boolean interruptFalling = digitalRead(3) == LOW;
if(interruptFalling && isDebouncing()) return;
// digitalRead the pins; do stuff
}
void setup() {
pinMode(17, INPUT_PULLUP);
pinMode(16, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(3), wotHappnd, CHANGE);
}
boolean isDebouncing(){
unsigned int now = millis();
if(now - time_lastPressed > time_debounceLockout){
time_lastPressed = now;
return false;
}
return true;
}
void wotHappnd(){
boolean interruptFalling = digitalRead(3) == LOW;
if(interruptFalling && isDebouncing()) return;
// digitalRead the pins; do stuff
}
Internal pullups on all used pins.
My problem is that often (~4%), on interrupt, the interrupt pin is LOW all button pins are HIGH ("not pressed" - likely bouncing just as I read it). How to fix that?
Can't use delay during an interrupt; delayMicroseconds to wait for stable readout still feels inappropriate; a cap-based delay on the interrupt pin induces a period of floating. Prefer solutions in software or with no more than 1 extra component per input.
[edit] here's a claim that pin interrupts do some filtering already, which, if true, may make some solutions unreliable.
Buttons on separate interrupt pins work fine (triggered on FALLING), bouncing is handling by forcing a 80ms lockout period during which further presses are ignored. I like that solution for being lightweight.
My goal is to have 1 interrupt handle all events (buttons and other digital inputs). I don't want to depend on loop(), I wish to be free to use delay often rather than timer interrupts.
Most buttons execute an action when pressed, some, while pressed.
What I have now (just 2 buttons for now):
schematic
simulate this circuit – Schematic created using CircuitLab
void setup() {
pinMode(17, INPUT_PULLUP);
pinMode(16, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(3), wotHappnd, CHANGE);
}
boolean isDebouncing(){
unsigned int now = millis();
if(now - time_lastPressed> time_debounceLockout){
time_lastPressed = now;
return false;
}
return true;
}
void wotHappnd(){
boolean interruptFalling = digitalRead(3) == LOW;
if(interruptFalling && isDebouncing()) return;
// digitalRead the pins; do stuff
}
Internal pullups on all used pins.
My problem is that often (~4%), on interrupt, the interrupt pin is LOW all button pins are HIGH ("not pressed" - likely bouncing just as I read it). How to fix that?
Can't use delay during an interrupt; delayMicroseconds to wait for stable readout still feels inappropriate; a cap-based delay on the interrupt pin induces a period of floating. Prefer solutions in software or with no more than 1 extra component per input.
[edit] here's a claim that pin interrupts do some filtering already, which, if true, may make some solutions unreliable.
Buttons on separate interrupt pins work fine (triggered on FALLING), bouncing is handling by forcing a 80ms lockout period during which further presses are ignored. I like that solution for being lightweight.
My goal is to have 1 interrupt handle all events (buttons and other digital inputs). I don't want to depend on loop(), I wish to be free to use delay often rather than timer interrupts.
Most buttons execute an action when pressed, some, while pressed.
What I have now (just 2 buttons for now):
schematic
simulate this circuit – Schematic created using CircuitLab
void setup() {
pinMode(17, INPUT_PULLUP);
pinMode(16, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(3), wotHappnd, CHANGE);
}
boolean isDebouncing(){
unsigned int now = millis();
if(now - time_lastPressed > time_debounceLockout){
time_lastPressed = now;
return false;
}
return true;
}
void wotHappnd(){
boolean interruptFalling = digitalRead(3) == LOW;
if(interruptFalling && isDebouncing()) return;
// digitalRead the pins; do stuff
}
Internal pullups on all used pins.
My problem is that often (~4%), on interrupt, the interrupt pin is LOW all button pins are HIGH ("not pressed" - likely bouncing just as I read it). How to fix that?
Can't use delay during an interrupt; delayMicroseconds to wait for stable readout still feels inappropriate; a cap-based delay on the interrupt pin induces a period of floating. Prefer solutions in software or with no more than 1 extra component per input.
[edit] here's a claim that pin interrupts do some filtering already, which, if true, may make some solutions unreliable.
Buttons on separate interrupt pins work fine (triggered on FALLING), bouncing is handling by forcing a 80ms lockout period during which further presses are ignored. I like that solution for being lightweight.
My goal is to have 1 interrupt handle all events (buttons and other digital inputs). I don't want to poll the button states independ on loop(), I wish to be free to use delay often rather than timer interrupts.
Most buttons execute an action when pressed, some, while pressed.
What I have now (just 2 buttons for now):
schematic
simulate this circuit – Schematic created using CircuitLab
void setup() {
pinMode(17, INPUT_PULLUP);
pinMode(16, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(3), wotHappnd, CHANGE);
}
boolean isDebouncing(){
unsigned int now = millis();
if(now - time_lastPressed> time_debounceLockout){
time_lastPressed = now;
return false;
}
return true;
}
void wotHappnd(){
boolean interruptFalling = digitalRead(3) == LOW;
if(interruptFalling && isDebouncing()) return;
// digitalRead the pins; do stuff
}
Internal pullups on all used pins.
My problem is that often (~4%), on interrupt, the interrupt pin is LOW all button pins are HIGH ("not pressed" - likely bouncing just as I read it). How to fix that?
Can't use delay during an interrupt; delayMicroseconds to wait for stable readout still feels inappropriate; a cap-based delay on the interrupt pin induces a period of floating. Prefer solutions in software or with no more than 1 extra component per input.
[edit] here's a claim that pin interrupts do some filtering already, which, if true, may make some solutions unreliable.
Buttons on separate interrupt pins work fine (triggered on FALLING), bouncing is handling by forcing a 80ms lockout period during which further presses are ignored. I like that solution for being lightweight.
My goal is to have 1 interrupt handle all events (buttons and other digital inputs). I don't want to poll the button states in loop(), I wish to be free to use delay often rather than timer interrupts.
Most buttons execute an action when pressed, some, while pressed.
What I have now (just 2 buttons for now):
schematic
simulate this circuit – Schematic created using CircuitLab
void setup() {
pinMode(17, INPUT_PULLUP);
pinMode(16, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(3), wotHappnd, CHANGE);
}
boolean isDebouncing(){
unsigned int now = millis();
if(now - time_lastPressed> time_debounceLockout){
time_lastPressed = now;
return false;
}
return true;
}
void wotHappnd(){
boolean interruptFalling = digitalRead(3) == LOW;
if(interruptFalling && isDebouncing()) return;
// digitalRead the pins; do stuff
}
Internal pullups on all used pins.
My problem is that often (~4%), on interrupt, the interrupt pin is LOW all button pins are HIGH ("not pressed" - likely bouncing just as I read it). How to fix that?
Can't use delay during an interrupt; delayMicroseconds to wait for stable readout still feels inappropriate; a cap-based delay on the interrupt pin induces a period of floating. Prefer solutions in software or with no more than 1 extra component per input.
[edit] here's a claim that pin interrupts do some filtering already, which, if true, may make some solutions unreliable.
Buttons on separate interrupt pins work fine (triggered on FALLING), bouncing is handling by forcing a 80ms lockout period during which further presses are ignored. I like that solution for being lightweight.
My goal is to have 1 interrupt handle all events (buttons and other digital inputs). I don't want to depend on loop(), I wish to be free to use delay often rather than timer interrupts.
Most buttons execute an action when pressed, some, while pressed.
What I have now (just 2 buttons for now):
schematic
simulate this circuit – Schematic created using CircuitLab
void setup() {
pinMode(17, INPUT_PULLUP);
pinMode(16, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(3), wotHappnd, CHANGE);
}
boolean isDebouncing(){
unsigned int now = millis();
if(now - time_lastPressed> time_debounceLockout){
time_lastPressed = now;
return false;
}
return true;
}
void wotHappnd(){
boolean interruptFalling = digitalRead(3) == LOW;
if(interruptFalling && isDebouncing()) return;
// digitalRead the pins; do stuff
}
Internal pullups on all used pins.
My problem is that often (~4%), on interrupt, the interrupt pin is LOW all button pins are HIGH ("not pressed" - likely bouncing just as I read it). How to fix that?
Can't use delay during an interrupt; delayMicroseconds to wait for stable readout still feels inappropriate; a cap-based delay on the interrupt pin induces a period of floating. Prefer solutions in software or with no more than 1 extra component per input.
[edit] here's a claim that pin interrupts do some filtering already, which, if true, may make some solutions unreliable.