Go Down

Topic: not declared in this scope (Read 1 time) previous topic - next topic

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

Coding Badly


Code: [Select]
boolean ledOn = false;
...lower case n

Code: [Select]
     ledON = !ledON;
...
   digitalWrite(ledPin,ledON);

...upper case N

ematson5897

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


MarkT

Indeed you have to spell consistently including case to program.  Or use an editor with auto-complete on variable names.
[ I won't respond to messages, use the forum please ]

UKHeliBob


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 ?
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

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

PaulS

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

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