Covid brain has struck!

  if  (digitalRead(reset) == LOW), digitalWrite(pin52) == HIGH);

I am just trying to switch a relay that will shut down a OLED when a sensor senses an obstacle. the sensor switches reset low and i want to send a signal high to the signal pin of the relay.

if  (digitalRead(reset) == LOW)
     digitalWrite(pin52, HIGH);

Is that comma meant to be there ?

Im still a noob. what are the outcomes of having it and not having it

What happened when you tried to upload the code line with the comma in it ?

if  (digitalRead(reset) == LOW)
        , digitalWrite(pin52) == HIGH);

the comma is outside the if condition making it part of the body of the if

but a "," used in that way is not valid

and presumably you didn't intend to make a comparison to HIGH and did intent the "HIGH" to be the 2nd argument to the digitalWrite (), setting pin52 to HIGH

I will get back to you guys later. I am crashing hard. Covid ain't no joke!!

never mind, opening my eyes slowly…

Not in the code you quoted. That would fail to compile because digitalWrite is not provided two arguments.

With two arguments, the statement becomes syntactically correct and does nothing but the digitalWrite, onaconna that misplaced and certainly not what s/he wanted semicolon.


this is the error i get without the comma
"too few arguments to function 'void digitalWrite(uint8_t, uint8_t)' "

this is the error i get with the comma
"expected primary-expression before ',' token"

both of these are from this line

if  (digitalRead(reset) == LOW),
     digitalWrite(pin52 HIGH);  }

Here is a link to 'if' on the reference page. It's worth having a look...

HEY!! that did it. it uploaded only one issue. i have looked at that link so many times and it never clicked. Damn dont program on COVID i guess. One issue is that it doesnt do what im asking. ill dig in more and see if i can figure this out.

thank you

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