3 error messages, I'm not sure what's wrong. (Arduino UNO)

I'm new to coding and Arduino's altogether. My teacher only skimmed over it in my virtual course, and he isn't responding to his emails. I can't find what's wrong, but I have three error messages. They're all simple so I know it'll be obvious, but again, I've never done this.

I'm just doing a simple thing where there is a green light that will turn on, and when I press a pushbutton the two red LEDs will flash, and then the green one will turn off. Thanks for any help!

In function 'void loop()':
17:2: error: 'else' without a previous 'if'
exit status 1

int switchState = 0;
void setup(){
 pinMode(3,OUTPUT);
 pinMode(4,OUTPUT);
 pinMode(5,OUTPUT);
 pinMode(2,INPUT);
}
  void loop(){
 switchState = digitalRead(2);
  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, HIGH);
 delay(250); // wait for a quarter second
 // toggle the LEDs
 digitalWrite(4, HIGH);
 digitalWrite(5, LOW);
 delay(250); // wait for a quarter second
} // go back to the beginning of the loop

if(switchState = LOW) This is wrong syntax, see = vs ==

You have no braces { and } associated with your if()

Look at how to use if() in the reference section.

See:

Thank youuu :cry: :cry: :cry: :cry:

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.