I don't know if this is the right place to ask... but I'm gonna ask... is there a simpler way to write ...... if (!digitalRead(buttonPin1[0]) == HIGH) { count = 1; } else if (!digitalRead(buttonPin1[1]) == HIGH) { count = 2; } else if (!digitalRead(buttonPin1[2]) == HIGH) { count = 3; } ................ I want a simpler bit of code that spits out a number of which button is pressed without writing a massive long list of 'else if's'. Just wondering. Any help would be greatly appreciated.
I don't know if this is the right place to ask... but I'm gonna ask... is there a simpler way to write ...... if (!digitalRead(buttonPin1[0]) == HIGH) {
count = 1;
}
else if (!digitalRead(buttonPin1[1]) == HIGH) {
count = 2;
}
else if (!digitalRead(buttonPin1[2]) == HIGH) {
count = 3;
}
................ I want a simpler bit of code that spits out a number of which button is pressed without writing a massive long list of 'else if's'. Just wondering. Any help would be greatly appreciated.