compiling program

This program continues to produce a "expected unqualified id before numeric contant for line 17.

1 int switchState = 0;

2 void setup() {
3 pinMode(3, OUTPUT);
4 pinMode(4, OUTPUT);
5 pinMode(5, OUTPUT);
6 pinMode(2, INPUT);
7
}
8 void loop() {
9 switchState = digitalRead(2);
10
}
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, HIGH);

21 delay(250); // wait for a quarter second
22 // toggle the LEDs
23 digitalWrite(4, HIGH);
24 digitalWrite(5, LOW);
25 delay(250); // wait for a quarter secon
26
}
27 } // go back to the beginning of the loop

Because you have posted the line numbers for your code it is impossible (without a lot of editing) to study your code in a text editor. The text editor will number the lines without interfering with the program code.

When posting code please use the code button </>
codeButton.png

so your code looks like this

See How to use the Forum

...R

Please post the code as described in the how to use this forum-please read stickies. Please remove the line numbers and auto format (ctrl-t or Tools, Auto Format) before posting so that we can load the code into the IDE for examination.

You closed loop() as soon as you do digitalRead(), the rest of the code is left out.

LOW is spelled "LOW", not "low"

Please stop creating new topics for the same problem.

Duplicates deleted.