Hello,
I copied this project from a starter kit and have googled on the error "expected unqualified id before numeric constant" for the Arduino Uno board. Made several changes to the code, but I am still getting the same error. Can you help me troubleshoot this situation, please?
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
8 void loop(){
9 switchState = digitalRead(2);
10 // this is a comment
11 if (switchState==LOW) {
12 // the button is not pressed
13 digitalWrite(3, HIGH); // green LED
14 digitalWrite(4, LOW); // red LED
15 digitalWrite (5, LOW); // red LED
16 }
17 else{ // the button is pressed
18 digitalWrite(3, LOW);
19 digitalWrite (4, LOW);
20 digitalWrite (5,LOW);
21 delay (250); // wait for a quarter of a second
22 // toggle the LEDS
23 digitalWrite (4,HIGH);
24 digitalWrite (5, LOW);
25 delay(250);// wait for a quarter of a second
This compiles. Removed line numbers. Commented out extra setup() and loop() and fixed bad pinMode. Tidied up indent with autoformat tool (ctrl-t or Tools, Auto Format).
/* ______________remove the extra setup() and loop()__________
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}*/
int switchState = 0;
void setup()
{
pinMode(3, OUTPUT); // pinMODE?????
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(2, INPUT);
}
void loop()
{
switchState = digitalRead(2);
// this is a comment
if (switchState == LOW)
{
// the button is not pressed
digitalWrite(3, HIGH); // green LED
digitalWrite(4, LOW); // red LED
digitalWrite (5, LOW); // red LED
}
else // the button is pressed
{
digitalWrite(3, LOW);
digitalWrite (4, LOW);
digitalWrite (5, LOW);
delay (250); // wait for a quarter of a second
// toggle the LEDS
digitalWrite (4, HIGH);
digitalWrite (5, LOW);
delay(250);// wait for a quarter of a second
}
} // go back to the beginning of the loop
Read the how to use this forum-please read sticky to see how to properly post code and some advice on how to ask an effective question. Remove useless white space and format the code with the IDE autoformat tool (crtl-t or Tools, Auto Format) before posting code.