Hello
I am new to esp32.
I am trying to use Boolean Logic.
c = a && b,
c = a and b.
Neither works and compiler make no error ! (a, b is inputpins).
I have bin struggle a long time !
I hope someone has a solution!
Lelleprinter
Hello
I am new to esp32.
I am trying to use Boolean Logic.
c = a && b,
c = a and b.
Neither works and compiler make no error ! (a, b is inputpins).
I have bin struggle a long time !
I hope someone has a solution!
Lelleprinter
Are you trying to use boolean logic on the pin numbers (if so then why ?) or boolean logic on the state of the pins (if so then why no digitalRead()s) ?
Either way, please post a complete but small sketch that illustrates the problem (use code tags) and explain what "Neither works" means
To do what?
Please take a few moments to describe what you are actually trying to do.
I'm sure it works so the question is, why do you think it's not working?
Are the variables all defined as bool? (That's not strictly necessary but it makes things "cleaner".)
"print" the values of a, b, and c to show us what's going wrong.
The complier only checks for syntax errors. It doesn't know what your program is supposed to accomplish and it can't check for logical errors.
Both work but the results might not be what you are expecting.
c = a && b
is not a boolean operation it is a logic "and" and is only used in if statements. In other words it is not a bit wise and operation.
Similarly
c = a and b is not a bit wise operation this would be a bit wise operation:-
c = a & b
This might help you:-
bool c = digitalRead (PinA) && digitalRead (PinB);
not
bool c = PinA && PinB;
Sorry! I found a misconnection and the same in main brain! Printing a, b, c made my brain to wake up!
Thank you for your engagement!
Lelleprinter
Something seems to have happened when you translated what you were trying to say from Swedish to English because I don't understand any of it
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.