Go Down

Topic: Was not declared in scope (Read 853 times) previous topic - next topic

keldar

I have just started programming with the Arduino Uno and have had good success using the examples that came with the kit. I am trying  to expand on the projects but I am having a trouble with the sketch. I get an Error message"ledPin2 was not declared in this scope" . Can any one point out what I am missing?
Code: [Select]
int sensorPin1 = 0;
int ledPin1 = 13;
int ledpin2 = 12;
int sensorValue1 = 0;

void setup()
{

  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
 
  Serial.begin(9600);
}
void loop()                     
{
int threshold1 = 150;
int threshold2 = 180;
if(analogRead(sensorPin1) > threshold1){ digitalWrite(ledPin1, HIGH);}
else{ digitalWrite(ledPin1, LOW);}

if(analogRead(sensorPin1) > threshold2){ digitalWrite(ledPin2, HIGH);}
else{ digitalWrite(ledPin2, LOW);}

float temperature = getVoltage(sensorPin1); 
temperature = (temperature - .5) * 100;                                                         
Serial.println(temperature);                     
delay(1000);


}
float getVoltage(int pin){
return (analogRead(pin) * .004882814);                                     
}


Arrch


retrolefty

int ledpin2 = 12;

You probably meant int ledPin2 = 12; as that is what you called it else where in your sketch. C/C++ is case sensitive.

Lefty

keldar

Wow thanks for the help. I must be going bug eyed. I looked at that a 100 times and couldnt see that.

thanks

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy