Starter Kit Project 03 Temperature Configuration

I’m trying to do Project 03 in the starter kit, but I’m running into a problem with the temperature.
No matter what I change the default temperature to, it always changes right after I reset it and when I put my finger on the sensor, the temperature doesn’t always go back down. Is there any way I can fix this?
Here’s the code:

const int sensorPin = A0;
const float baselineTemp = 22.0;
void setup(){
  for(int pinNumber = 2; pinNumber<5; pinNumber++){
    digitalWrite(pinNumber, LOW);

void loop() {
  int sensorVal = analogRead(sensorPin);
  Serial.print("Sensor Value: ");
  float voltage = (sensorVal/1024.0) * 5.0;
  Serial.print(", Volts: ");
  Serial.print(", degrees C: ");
  float temperature = (voltage - .5) * 100;
  if(temperature < baselineTemp){
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
  }else if(temperature >= baselineTemp+2 && temperature < baselineTemp+4){
    digitalWrite(2, HIGH);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
  }else if(temperature >= baselineTemp+4 && temperature < baselineTemp+6){
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
    digitalWrite(4, LOW);
  }else if(temperature >= baselineTemp+6){
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
    digitalWrite(4, HIGH);

I don't understand how you change the "default" temperature?

It's normal that a temperature sensor takes some time to return to room temperature. What's your room temperature, what's the program output?

If the shown temperature does not match the room temperature, something is wrong with the sensor or with your wiring.

I'm not sure what the room temperature is, I don't have a thermometer. It said in the book that their was a way to check the temperature and save that as the baselineTemp but I can't find the instructions how.

Usually the temperature at start of the program can be taken as the current room temperature. But this temperature is interesting only for debugging, the LEDs are switched depending on more or less hot body temperature.

I need to figure out how to, at the start of the program, measure the room temperature, and save it as the baselineTemp. Then, the rest of the code remains unchanged.

Take a first reading of the sensor and save it as the room temperature.

That's what i'm asking for help with. I dn't know how to do that.

You read the temperature from the sensor initially…set your first reading as the baseline temperature.

//declare this variable in your program

boolean firstTime = true;

// in your main loop put this right after you calculate the temperature from the sensor

if (firstTime = true) { baselineTemp = temperature; firstTime = false; }