Pages: [1]   Go Down
Author Topic: Was not declared in scope  (Read 593 times)
0 Members and 1 Guest are viewing this topic.
Ontario Canada
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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);                                     
}

Logged

California
Offline Offline
Faraday Member
**
Karma: 88
Posts: 3380
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Case sensitivity
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17294
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Ontario Canada
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

thanks
Logged

Pages: [1]   Go Up
Jump to: