exit status 1 "expected unqualified-id" Help

I have been having issue with this code, can someone help me with this?

spaceship_apr22a:21: error: expected unqualified-id before 'else'

else{ //Button is pressed.


exit status 1 expected unqualified-id before 'else'

I have copied the complete code below:

int switchState = 0; void setup() { pinMode(3, OUTPUT); pinMode(4, OUTPUT); pinMode(5, OUTPUT); pinMode(2, INPUT); } void loop() { switchState = digitalRead(2); // Void Loops this is the sequence that runs continuously after //void set up (runs once on start up, and can be used to assign the INPUT & OUTPUT of digital pins). if (switchState ==LOW) // The button is not pressed digitalWrite (3, HIGH); //Green LED digitalWrite (4, LOW); //Red LED digitalWrite (5, HIGH); //Red LED 2 delay(250); digitalWrite(5,LOW); delay(250); } else{ //Button is pressed. digitalWrite(3,LOW); digitalWrite(4, LOW); digitalWrite(5,HIGH); delay(250); digitalWrite(4,HIGH); digitalWrite(5,LOW); delay(250); }

if (switchState ==LOW)

Did you miss a { ?

also missing a '}' at the end to close off loop().

Also, in the futureā€¦

To post:

  1. Use CTRL-T in the Arduino IDE to autoformat your code.
  2. Paste the autoformatted code between code tags (the </> button)
    so that we can easily see and deal with your code.