Hello,
I have been following the Arduino Projects Book and I can't get the Love-O-Meter project to upload. I have even copied the code off of the site. Appreciate any help.
const int sensorPin = A0;
const float baselineTemp = 20.0;
void setup(){
Serial.begin(9600);
for(int pinNumber = 2; pinNumber < 5; pinNumber++){
pinMode(pinNumber, OUTPUT);
digitalWrite(pinNumber, LOW);
}
}
void loop(){
int sensorVal = analogRead(sensorPin);
Serial.print("Sensor Value: ");
Serial.print(sensorVal);
float voltage = (sensorVal/1024.0)*5.0;
Serial.print(", Volts: ");
Serial.print(voltage);
Serial.print(", degrees C: ");
float temperature = (voltage-0.5)*100;
Serial.println(temperature);
if(temperature < baselineTemp){
digitalWrite(2,LOW);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
}elseif(temperature >= baselineTemp+2 && temperature < baselineTemp+4){
digitalWrite(2,HIGH);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
}elseif(temperature >= baselineTemp+4 && temperature < baselineTemp+6){
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,LOW);
}elseif(temperature >= baselineTemp+6){
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
}
delay(1);
}
C:\Users\Michael\AppData\Local\Temp\build1453341792410\Project2.cpp: In function 'void loop()': C:\Users\Michael\AppData\Local\Temp\build1453341792410\Project2.cpp:44:74: error: 'elseif' was not declared in this scope }elseif(temperature >= baselineTemp+2 && temperature < baselineTemp+4){ ^ C:\Users\Michael\AppData\Local\Temp\build1453341792410\Project2.cpp:44:75: error: expected ';' before '{' token }elseif(temperature >= baselineTemp+2 && temperature < baselineTemp+4){ ^ C:\Users\Michael\AppData\Local\Temp\build1453341792410\Project2.cpp:50:75: error: expected ';' before '{' token }elseif(temperature >= baselineTemp+4 && temperature < baselineTemp+6){ ^ C:\Users\Michael\AppData\Local\Temp\build1453341792410\Project2.cpp:56:43: error: expected ';' before '{' token }elseif(temperature >= baselineTemp+6){ ^ C:\Users\Michael\AppData\Local\Temp\build1453341792410\Project2.cpp: At global scope: C:\Users\Michael\AppData\Local\Temp\build1453341792410\Project2.cpp:64:12: error: redefinition of 'const int sensorPin' }const int sensorPin = A0; ^ C:\Users\Michael\AppData\Local\Temp\build1453341792410\Project2.cpp:6:11: error: 'const int sensorPin' previously defined here const int sensorPin = A0; ^ C:\Users\Michael\AppData\Local\Temp\build1453341792410\Project2.cpp:65:13: error: redefinition of 'const float baselineTemp' const float baselineTemp = 20.0; ^ C:\Users\Michael\AppData\Local\Temp\build1453341792410\Project2.cpp:7:13: error: 'const float baselineTemp' previously defined here const float baselineTemp = 20.0; ^ C:\Users\Michael\AppData\Local\Temp\build1453341792410\Project2.cpp: In function 'void setup()': C:\Users\Michael\AppData\Local\Temp\build1453341792410\Project2.cpp:67:6: error: redefinition of 'void setup()' void setup(){ ^ C:\Users\Michael\AppData\Local\Temp\build1453341792410\Project2.cpp:9:6: error: 'void setup()' previously defined here void setup(){ ^ C:\Users\Michael\AppData\Local\Temp\build1453341792410\Project2.cpp: In function 'void loop()': C:\Users\Michael\AppData\Local\Temp\build1453341792410\Project2.cpp:75:6: error: redefinition of 'void loop()' void loop(){ ^ C:\Users\Michael\AppData\Local\Temp\build1453341792410\Project2.cpp:21:6: error: 'void loop()' previously defined here void loop(){ ^