Problem incrementing in ISR

This project requires me to use an interrupt (project requirement, not that I think it cant be done without it). The problem I am running into is the variable “ticket” is incrementing by more than 1 when one of the two interrupt buttons is pushed. I do have a 1 kohm “debounce” resistor between the buttons DI and ground.

The window variable swaps correctly between 1 and 2 depending on which button is pressed.

But the ticket jumps by 2 or 3 rather than incrementing by 1 as desired. Thank you for your time!

//a program that dispays the window number and ticket number for customers to be served. The window operator presses button to call next ticket to their window)

#include <LiquidCrystal.h>

volatile byte window = 1,ticket = 1;
const int rs = 12, en = 11, d4 = 7, d5 = 6, d6 = 5, d7 = 4, buttonIn = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() {
lcd.begin(16, 2);
pinMode(buttonIn, INPUT);
attachInterrupt (digitalPinToInterrupt(2), window1, HIGH);
attachInterrupt (digitalPinToInterrupt(3), window2, HIGH);
lcd.print ("Now Serving");
lcd.setCursor (0, 1);
lcd.print ("at window");
}

void loop() {
lcd.setCursor (12, 0);
lcd.print (ticket);
lcd.setCursor (11, 1);
lcd.print (window);
}

void window1 ()
{
 window = 1;
 ++ticket;
 delayMicroseconds(16383);
}

void window2 ()
{
  window = 2;
  ++ticket; 
delayMicroseconds(16383);
}

Update; I found a suggestion for debouncing inside a ISR on another post and tried it. It now works sometimes, but will still increment by 2 instead of 1 on occasion. The change is I declared a volatile int intDebounce and changed ISR as follows;

 void window1 ()
{if (intDebounce>millis()) return;
 window = 1;
 ++ticket;
 intDebounce=millis()+10;
}

void window2 ()
{if (intDebounce>millis()) return;
  window = 2;
  ++ticket;
   intDebounce=millis()+10;
}

Actually the fix above worked, I had a mistake in it initially. It is incrementing correctly.

attachInterrupt (digitalPinToInterrupt(2), window1, HIGH);
attachInterrupt (digitalPinToInterrupt(3), window2, HIGH);

What Arduino are you using? HIGH is only valid for Due, Zero, MKR1000. On other achitectures HIGH is the same as CHANGE. https://www.arduino.cc/reference/en/language/functions/external-interrupts/attachinterrupt/

I do have a 1 kohm "debounce" resistor between the buttons DI and ground.

Hardware debounce typically involves a capacitor, so I'm not sure what you have. Is this a pulldown resistor to keep the input from floating. How is the button wired?

Preferred method is to use INPUT_PULLUP and wire the push button between the input pin and ground. Pressing the switch will pull the input low. When the switch is not pressed, the internal pullup resistor keeps the input at 5v and not floating.

delayMicroseconds(16383);

This is a very poor way to attempt software debounce. It make the ISR way too long, and there can be other impacts. Typically you would use a lockout condition in the ISR.

void myDebouncedISR()
{
 static unsigned long last_interrupt_time = 0;
 unsigned long interrupt_time = millis();
 if (interrupt_time - last_interrupt_time > 100) //lock out period
 {
   //do the thing
 }
 last_interrupt_time = interrupt_time;

}

TeslaFet: I do have a 1 kohm "debounce" resistor between the buttons DI and ground.

A resistor cannot debounce an input. Only a capacitor can. Or, you can do it in software. But a resistor, no matter how you connect it, will do nothing useful about switch bounce.

Regards, Ray L.