Problem testing for more than 1 button test

I found this code for checking if a button on digital pin 2 has been pressed and it works fine. However I would like to also use pin 10. So if digital pin 2 is pressed or digital pin 10 is pressed then go and start the program. Not sure how to do this, but any help would be appreciated.
Thanks

   const byte buttonPin = 2;
    pinMode(buttonPin, INPUT_PULLUP);
    while (digitalRead(buttonPin) == HIGH)
 const byte buttonPin = 2;
const byte buttonPin10 = 10;
    pinMode(buttonPin, INPUT_PULLUP);
pinMode(buttonPin10, INPUT_PULLUP);
    while ( (digitalRead(buttonPin) == HIGH) || ((digitalRead(buttonPin) == HIGH) ) 

Just do a OR (||) with a similar condition

That is great, thank so much for the help.

Ok so i have this, it compiles but doesn't work?

 const byte buttonPin = 2;
const byte buttonPin10 = 10;
    pinMode(buttonPin, INPUT_PULLUP);
pinMode(buttonPin10, INPUT_PULLUP);
    while ( (digitalRead(buttonPin) == HIGH) || (digitalRead(buttonPin10) == HIGH) ); 

Troubleshooting "doesn't work" and code snippets is, from my end, a wild guess.

Using OR, you will need to press BOTH buttons to get out of the while.

is there another command i can use instead of or?

This will wait until EITHER button is pressed (assuming the input goes LOW when a button is pressed, which is normal when using INPUT_PULLUP):

while ( (digitalRead(buttonPin) == HIGH) && (digitalRead(buttonPin10) == HIGH) ); 

WOW, thank you so much, I just tested and it worked flawless.
Thank YOU!!!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.