Love_O_Meter (pinNumber not declared in scope issue, line 5)

Hi, I have entered the sketch from the Arduino projects book – Love_O_Meter. When I try to verify I get an error relating to line 5 of the sketch that says;

‘pinNumber’ was not declared in this scope

const int sensorPin = A0;
const float baselineTemp = 20.0;
void setup() {
Serial.begin(9600); // open a serial port
for(int pinNnumber = 2; pinNumber<5; pinNumber++){
pinMode(pinNumber, OUTPUT);
digitalWrite(pinNumber, LOW);
}
}

void loop() {
int sensorVal = analogRead(sensorPin); //
Serial.print("Sensor Value: ");
Serial.print(sensorVal);
//convert the ADC reading to voltage
float voltage = (sensorVal/1024.0) * 5.0;
Serial.print(", Volts: ");
Serial.print(voltage);
Serial.print(", degrees C: ");
// convert the voltage to temperature in degrees
float temperature = (voltage - .5) * 100;
Serial.println(temperature);
if(temperature < baselineTemp+2){
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){
temperature < baselineTemp+4){
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
}
delay(1);
}

‘pinNumber’ was not declared in this scope

Can someone help me understand why this error comes up? I believe I have entered everything as shown in the book.
There is a similar topic at the Arduino forum, but it doesn't help me out either.

Thanks in advance!

mve92

look closely….

One can declare that constant

One can declare that constant.

But one does not want to declare pinNumber as a thingy, why not?

something like

int pinNumber[5] = {1,2,3,4,5};

was not copied.

omg... I'm sorry, just looked over it I guess. :face_with_open_eyes_and_hand_over_mouth:
Thanks for helping me out here so quickly!

Nnevermind.

a7

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.