When I press a button I want the other functions that are happening to stop. How do you do so.
const int buttonPin1 = 2;
const int buttonPin2 = 3;
const int buttonPin3 = 4;
const int buttonPin4 = 5;
int buttonState1 = 0;
int buttonState2 = 0;
int buttonState3 = 0;
int buttonState4 = 0;
void setup() {
// initialize the pushbutton pin as an input:
pinMode(buttonPin1, INPUT);
pinMode(buttonPin2, INPUT);
pinMode(buttonPin3, INPUT);
pinMode(buttonPin4, INPUT);
}
void loop() {
// read the state of the pushbutton value:
buttonState1 = digitalRead(buttonPin1);
buttonState2 = digitalRead(buttonPin2);
buttonState3 = digitalRead(buttonPin3);
buttonState4 = digitalRead(buttonPin4);
//4 functions
if (buttonState1 == HIGH) {
//function here
//terminate
}
if (buttonState2 == HIGH) {
//function here
//terminate
}
if (buttonState3 == HIGH) {
//function here
//terminate
}
if (buttonState4 == HIGH) {
//function here
//terminate
}
}