Yes, I'm a "newbie." Gotta start somewhere...
A larger program got me stuck at one spot, so I pulled it out, boiled it down to this little snippet, and loaded it .
I expect my result to be an LED that is OFF. The variable "TempSense", which is 247 according to the serial monitor, should make this false and be skipped. Yes?
But my LED flashes. No errors. Just not what I expected. Clearly, 247 is not less than 10, so I thought it would not "do what is in the braces."
I feel like such an idiot already, so please tread lightly.
What am I doing wrong?
This is the whole short thing:
const int RedLED = 4; // pin 4 attached to Red LED
void setup()
{
pinMode(RedLED, OUTPUT);
Serial.begin(9600); // initialize serial communication at 9600 bits per second:
}
void loop()
{int TempSense1; // For reading the inputs on analog pins A0. This is the Voltage of the voltage divider circuit containing a thermistor.
digitalWrite(RedLED, LOW); //Turn it off to start
Sensors: // The sub-loop
TempSense1 = 0; //Make it zero to start
TempSense1 = analogRead(A0); //Read temp sensor (0-1024)
delay(2); // delay in between reads for stability
Serial.println("The value is: " );
Serial.println(TempSense1);
Serial.println(" "); // A blank line
if (TempSense1 < 10); //Remember, less value is higher temp here.
{
digitalWrite(RedLED, HIGH); //Fast flashing red led is too high temp.
delay(300); //Makes the LED flash
digitalWrite(RedLED, LOW);
delay(300); //Makes the LED flash
goto Sensors; //Go try again.
}
digitalWrite(RedLED, LOW);
}
The serial monitor says:
"The value is:
247"
(or sometimes 246 - it is a thermistor after all.)
I'm sure it's simple - I just can't see it. Grateful in advance....