If statements with both AND and OR

Its difficult for me to test the code so hoping for feedback on this line before I upload it to the arduino.

if (( pedalButtonState == 1 ) && (( timesPressed >= distributeperday || millis() - lastPress  < timerduration))

I want to do something when the button is pushed, and EITHER of the other two statements are true. I know I can create two separate if statements otherwise.

And what is wrong with this line, else that it is missing a closing parenthesis and a semi-colon at the end?

I think is OK other than the parenthesis at the end, but can’t check it easily right now. But wasn’t sure the AND/IF would work. Do the brackets break up the AND and IF statements?

I assume that the statement means that both the red and green sections need to be true , but either of the green statements make that part true?

(( pedalButtonState == 1 && (( timesPressed >= distributeperday || millis() - lastPress < timerduration)))

Pete-Repeat:
I think is OK other than the parenthesis at the end, but can’t check it easily right now. But wasn’t sure the AND/IF would work. Do the brackets break up the AND and IF statements?

I assume that the statement means that both the red and green sections need to be true , but either of the green statements make that part true?

(( pedalButtonState == 1 && (( timesPressed >= distributeperday || millis() - lastPress < timerduration)))

that’s the general idea except you are a little random on the ()

Sometimes its easier to write a small sketch and use serial print to prove that the code is correct (correct in the sense that it does what you think it does)

Pete-Repeat:
Its difficult for me to test the code

In that case it can be useful to split up the test onto several lines

if ( pedalButtonState == 1 ) {
   if ( timesPressed >= distributeperday) {
   
   }
   if( millis() - lastPress  < timerduration)) {
   
   }
}

as that allows you to add print() statements at different parts to monitor the behaviour.

…R

jbellavance:
And what is wrong with this line, else that it is missing a closing parenthesis and a semi-colon at the end?

Semicolons on the end of if statements are always a bad idea.

I know I can create two separate if statements otherwise.

That really is preferred. Much easier to debug nested ifs than compound ifs.