not declared in this scope

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"

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);
 }
boolean ledOn = false;

...lower case n

     ledON = !ledON;
...
   digitalWrite(ledPin,ledON);

...upper case N

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

Great minds think alike

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

MarkT:
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 ?

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

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? 8)

Im having a similar problem, however i have checked the capital letters and I can't seem to find why LedOn was not declared in scope. :confused:

Here is my Code:

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

void setup ()
{
pinMode (switchPin, INPUT);
pinMode (ledPin, OUTPUT);
}

boolean debounce(boolean last)
{
boolean current = digitalRead(switchPin);
if (last != current)
{
delay(5);
current = digitalRead(switchPin);
}
return current;
}

void loop ()
{
currentButton = debounce(lastButton);
if (lastButton == LOW && currentButton == HIGH)
{
ledOn = !ledOn;
}
lastButton = currentButton;
digitalWrite (ledPin, LedOn);
}

boolean ledOn = false;

contains small letter 'l' while
you use capital 'L' on

    lastButton = currentButton;
  digitalWrite (ledPin, LedOn);

aw god I would have sworn I had checked every inch of it as well! thanks a lot haha :))) :smiley: :smiley:

no problem.. it also happens to me sometimes..

UKHeliBob:
I would be interested in such an editor. Can you recommend one ?

Why anyone uses the Arduino IDE is beyond me. Get AtmelStudio, and get the free VisualMicro plug-in, and you have a modern development environment based on Microfost VisualStudio that works really well. When you get a compiler error, simply double-click on the error message, and it takes you right to the line that caused the error. If has "Intellisense", so will auto-complete variabe and function names for you. It uses the Arduino tools to do the build, so it is 100% compatible with the Arduino IDE.

Regards,
Ray L.