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

My "setup" and "loop" from "void loop()" and "voidsetup()" aren't bold...
they used to always be whenever i typed them into the ide.

 Also now there is an error message saying
"ledOn' was not declared in this scope"

Code:
int switchPin = 8;
int ledPin = 13;
boolean lastButton = LOW;
boolean ledOn = false;

void setup()
{
  pinMode(switchPin, INPUT);
  pinMode(ledPin, OUTPUT);
}
  void loop()
 {
   if(digitalRead(switchPin) == HIGH && lastButton == LOW)
   {
     ledON = !ledON;
    lastButton = HIGH;
   }
   else
   {
     lastButton = digitalRead(switchPin);
   }
   digitalWrite(ledPin,ledON);
 }
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 177
Posts: 12288
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


Code:
boolean ledOn = false;
...lower case n

Code:
     ledON = !ledON;
...
   digitalWrite(ledPin,ledON);
...upper case N
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 197
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The error message is because you declare it as ledOn, with a lowercase n, but try to use ledON, with an uppercase N.
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 197
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Great minds think alike
Logged

0
Offline Offline
Shannon Member
****
Karma: 162
Posts: 10489
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Indeed you have to spell consistently including case to program.  Or use an editor with auto-complete on variable names.
Logged

[ I won't respond to messages, use the forum please ]

East Anglia (UK)
Offline Offline
Faraday Member
**
Karma: 90
Posts: 3514
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Indeed you have to spell consistently including case to program.  Or use an editor with auto-complete on variable names.
I would be interested in such an editor.  Can you recommend one ?
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thanks so much to everyone, obviously i am new to miss something like this, but i am just following what all these tutorials tell me to do so i can learn the language. i knew here would be the place to come, any other forum if you ask a simple question they just bash you and give you no answers.. guess i couldve figured it out haha sometimes you need a fresh set of eyes
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 551
Posts: 46224
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
any other forum if you ask a simple question they just bash you and give you no answers..
If that's what you wanted, why didn't you say so?  smiley-cool
Logged

Pages: [1]   Go Up
Jump to: