Super simple but...I don't get why...a little help please.

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....

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.
}

see the if(TempSense1 < 10); ? Well when you put a semi-colon right there, the program reads like this...

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.

Also, dont use goto, its typically seen as bad programming, there are few cases where you would need to use this. Use a while loop or for loop instead

What's wrong with this line:

if (TempSense1 < 10);

Regards,
Ray L.

OH! I see. Yes, I understand about the goto thing. I'll work on changing that.

Thank you SO MUCH. I knew it was simple. Being a newbie sucks...

Don't use goto. You can achieve the same thing with another while loop.

I'll work on changing that.

Good. Very good. And all the best with your project. :slight_smile: