not sure what is going wrong in the code below, but it's a simplified code of a larger piece I'm trying to debug. I notice that the code seems to skip to the else statement even though the if statement is valid. Potential is set to analogRead(A0)
while (potential < 1023) {
Serial.println(analogRead(A0));
if (potential < 1023) {
if (potential > 200) {
Serial.println("cool");
} else {
Serial.println("low");
lcd.print("hello");
delay(1000);
}
}
Results in serial monitor show
235
low
324
low
I've also tried if (potential < 1023 && potential > 200) and if ((potential < 1023) && (potential >200)) to no avail.
Can anyone help, let me know what's going wrong or suggest a fix to this?