Is it possible to have an OR or an AND statement in a comparison in an if statement?
EG:
if (Serial.available() or Variable2=true)
Is it possible to have an OR or an AND statement in a comparison in an if statement?
EG:
if (Serial.available() or Variable2=true)
It's been a while, but I think you want
|| for our
&& for and
and don't forget == for comparison and = for assignment
ie:
if (Serial.available() || Variable2==true)
Excellent! Thanks
The underlying C++ compiler does recognize the keyword or and and, so you can use:
void setup() {
// put your setup code here, to run once:
int a = 5;
int b = 6;
Serial.begin(115200);
if (a != b and b == 5)
Serial.println("True");
if (a == 5 or b == 6)
Serial.println("True");
}
void loop() {
}
Being an old C hack, I just can't get used to using those keywords and prefer || and &&.
econjack:
The underlying C++ compiler does recognize the keyword or and and,
…
Being an old C hack, I just can't get used to using those keywords and prefer || and &&.
As another old C hack: yuck. If I wanted to program in BASIC, I'd program in BASIC.