stuck in the first if statement

Hi guy’s i am pretty new to arduino programming, the task in question is when the temperature sensor reach certain temperature the servo motors turn on and then when the temperature goes below the threshold the motors turn back off… i can get the motors to turn on but they don’t turn back off.

#include <Servo.h>
Servo servo1;
Servo servo2;
int servoPos = 0;

int sensorValue = 0;
float analogReading = 0;
float degreesC = 0;


void setup() {
      int sensorValue = analogRead(A0);
      degreesC = (sensorValue * 500) /1024;
  
      servo1.attach(9); //define pins for pwm pins for servo's
      servo2.attach(11);
      Serial.begin(9600);
  
}

void loop() { // start of loop
    int sensorValue = analogRead(A0);
    degreesC = (sensorValue * 500) /1024;
    Serial.println(degreesC);
    delay(1000);
   
  while (degreesC >= 24)
  { // start of while loop

    if(true)
    { //Start of if
    
    for(servoPos = 0; servoPos < 180; servoPos++)// scann from 0-180 degrees
  { // start of for loop
    servo1.write(servoPos);
    servo2.write(servoPos);
    delay(10);
    Serial.print("first if ");
    Serial.println(degreesC);
    
  } //close for loop
  for(servoPos = 180; servoPos > 0; servoPos--) // scann from 180-0 degrees
  { // start of for loop
    servo1.write(servoPos);
    servo2.write(servoPos);
    delay(10);
     } // close for loop
    } // close of if

    if(false) 
    {
      for(servoPos = 0; servoPos < 0; servoPos++)// scann from 0-180 degrees
  { // start of for loop
    servo1.write(servoPos);
    servo2.write(servoPos);
    delay(10);
    
  } //close for loop
  for(servoPos = 0; servoPos > 0; servoPos--) // scann from 180-0 degrees
  { // start of for loop
    servo1.write(servoPos);
    servo2.write(servoPos);
    delay(10);
    Serial.print("second if ");
    Serial.println(degreesC);
     } // close for loop
    } // close of else
     
  } // close of  while loop
     
  } // close of loop

What is your explanation if these? if(true) . . . if(false) . . .

You do not up date degreesC in the 'while'

.

LarryD: What is your explanation if these? if(true) . . . if(false) . . .

You do not up date degreesC in the 'while'

.

Cheers i have now got it working :)