My first project don`t work...!!!


What`s wrong my project.... :(

 int switchState = 0;
 void setup(){
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(2, INPUT);
  void loop(){
  switchState = digitalRead(2);

  // this is 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, 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

Arduino: 1.8.0 (Windows 8.1), Kortti:"Arduino/Genuino Uno"

sketch_jan25a:20: error: expected unqualified-id before 'else'

else { // the button is pressed


sketch_jan25a:34: error: expected declaration before '}' token

} // go back to the beginning of the loop


exit status 1 expected unqualified-id before 'else'

This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences.

The { is missing after the if statement. It should be

if(switchState ==LOW) {

Thanx,it works..great!!