so im trying to get a baseline temp by pressing a switch. so that it is calibrated, however i keep getting an expected unqualifed-id before switch error. if I remove the variable and just put in the pin number to digital read it compiles fine, but not as a variable
float volts = 0;
float baselineTemp = 20.0;
int switchState=0;
int switch = 8;
void setup() {
pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
pinMode(A0,INPUT);
Serial.begin(9600);
pinMode(switch,INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int sensorValue = analogRead(A0);
Serial.print("Sensor Value: ");
Serial.print(sensorValue);
volts = (sensorValue / 1024.0) * 5.0;
Serial.print(" Voltate: ");
Serial.print(volts);
float temp = (volts - 0.5) * 100;
Serial.print(" Temperature: ");
Serial.println(temp);
delay(10);
if((digitalRead(switch)) == HIGH)
baselineTemp = analogRead(A0);
if(temp < baselineTemp){
for (int i = 2; i < 5; i++){
digitalWrite(i,LOW);
}
}
else if(temp > baselineTemp+2 && temp < baselineTemp+4){
digitalWrite(2,HIGH);
} else if(temp > baselineTemp+2 && temp < baselineTemp+4){
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
}else if(temp > baselineTemp+6){
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
}
}