I have received the expected unqualified-id before numeric constant error message for several lines of my code, but I just cannot figure out why. I am only trying the projects straight from the Arduino Projects Book, so I have followed their code exactly but I still get these messages for every project I have tried.
Here is the code for one of the projects:
1 const int sensorPin = AO;
2 const float baselineTemp = 20.0;
3 void setup (){
4 Serial.begin(9600); // open a serial port
5 for(int pinNumber = 2;
pinNumber<5;
pinNumber ++) {
6 pinMode(pinNumber, OUTPUT);
7 digitalWrite(pinNumber, LOW);
8 }
9}
10 void loop (){
11 int sensorVal = analogRead(sensorPin);
12 Serial.print("Sensor Value: ");
13 Serial.print(sensorVal);
14 // convert the ADC reading to voltage
15 float voltage = (sensorVal/1024.0) * 5.0;
16 Serial.print(" , Volts: ");
17 Serial.print(voltage);
18 Serial.print(" , degrees C: ");
19 // convert the voltage to temperature in degrees
20 float temperature = (voltage - .5) * 100;
21 Serial.println(temperature);
22 if(temperature < baselineTemp){
23 digitalWrite(2, LOW);
24 digitalWrite(3, LOW);
25 digitalWrite(4, LOW);
26 }
else if(temperature >= baselineTemp+4 &&
temperature < baselineTemp+4){
27 digitalWrite(2, HIGH);
28 digitalWrite(3, HIGH);
29 digitalWrite(4, LOW);
30 }
else if(temperature >= baselineTemp+4 &&
temperature < baselineTemp+6){
31 digitalWrite(2, HIGH);
32 digitalWrite(3, HIGH);
33 digitalWrite(4, LOW);
34 }
else if(temperature >= baselineTemp+6){
35 digitalWrite(2, HIGH);
36 digitalWrite(3, HIGH);
37 digitalWrite(4, HIGH);
38 }
39 delay(1);
40 }
I have highlighted in blue the lines that are reported by the program to have errors.
Line 2 is listed twice:
project3_aug01:2: error: expected unqualified-id before numeric constant
project3_aug01:3: error: expected unqualified-id before numeric constant
project3_aug01:1: error: expected unqualified-id before numeric constant
project3_aug01:2: error: expected unqualified-id before numeric constant
project3_aug01:4: error: expected unqualified-id before numeric constant
Please, help.