short btn1 = 3;
short btn2 = 2;
short lock = 0; //defines the button locking veriable
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(btn1, INPUT_PULLUP);
pinMode(btn2, INPUT_PULLUP);
}
void loop() {
// put your main code here, to run repeatedly:
if(digitalRead(btn1) == LOW){ //if button 1 is presed
if(lock != 1){ //if lock is not 1
//code that is locked in the if statement
Serial.println("btn1");
lock = 1; //locks this if statement untill lock is not 1
}
}
if(digitalRead(btn2) == LOW){ //if button 2 is pressed
if(lock != 2){ //if lock is not 2
//code that is locked in the if statement
Serial.println("btn2");
lock = 2; //locks this if statement untill lock is not 2
}
}
}