using a button as an increment

I am new to arduino and have been trying to work with sensors. i am currenty using arduino uno with a tmp36.

i have everything working and running, but i am trying to add 2 switchbuttons
1 will increase my base temp if high
1 will decrease my base temp if high

I am not sure but i want this to happen before the if statments for comparring temp and turning appropriate led based on current temp

const int tempSensor = A0;
// room temperature in Celcius
float baselineTemp = 72.5; // 26C = 79F
int switchState = 0;

void setup() {
// open a serial connection to display values
Serial.begin(9600);
pinMode(switchState, INPUT);
// set the LED pins as outputs
// the for() loop saves some extra coding
for (int pinNumber = 2; pinNumber < 7; pinNumber++) {
pinMode(pinNumber, OUTPUT);
digitalWrite(pinNumber, LOW);
}

}

void loop() {
// read the value on AnalogIn pin 0
// and store it in a variable
int sensorVal = analogRead(tempSensor);
int buttonState = digitalRead(switchState);

if (buttonState == 1){
baselineTemp++;
}

Serial.print("sensor Value: ");
Serial.print(sensorVal);

float voltage = (sensorVal / 1024.0) * 5.0;

Serial.print(", Volts: ");
Serial.print(voltage);

Serial.print(", Basline temp ");
Serial.println(baselineTemp);

Serial.print(", degrees C: ");
float temperatureC = (voltage - .5) * 100;
Serial.print(temperatureC);

Serial.print(", degrees F: ");
float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;
Serial.println(temperatureF);

// if the current temperature is lower than the baseline
// turn off all LEDs

if ((temperatureF >= baselineTemp - 0.8) && (temperatureF <= baselineTemp + 0.9)) {
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, HIGH);
// blue light

}else if (temperatureF < baselineTemp - 0.8) {
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, HIGH);
digitalWrite(6, LOW);

} // if the temperature rises 2-4 degrees, turn an LED on
else if (temperatureF >= baselineTemp + 2 && temperatureF < baselineTemp + 4) {
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
} // if the temperature rises 4-6 degrees, turn a second LED on
else if (temperatureF >= baselineTemp + 4 && temperatureF < baselineTemp + 6) {
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
} // if the temperature rises more than 6 degrees, turn all LEDs on
else if (temperatureF >= baselineTemp + 6) {
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
}

delay(1500);

}

Please edit your post and enclose the code in code tags (select and use the </> button).

Your logic is kind of OK (you obviously need to add a second switch) in that a button press increases the baseline temp. However as written even a brief press of the button will drive your baseline temp up by thousands. Your code needs to remember the previous buttonState and only increment baselineTemp when it goes from off to on.

However you will find that switch bounce will still make your results unpredictable: I suggest you read up on https://www.arduino.cc/en/Tutorial/Debounce

rw: His 1.5 sec delay should eliminate or reduce uncontrolled increases and bouncing effects, so it might work as-is. But it would be better practice if he took you up on your suggestions.

OP: In addition to what jr said, use auto-format (ctrl-T). And it would help if you asked a question. Your post implies a question but doesn't actually ask a question.

Apologies- I did miss the delay(1500) lurking there at the bottom which should, as Dave points out, make it work better than I initially thought.

OP-What happens to the system as its now written? In what way does it fail?