Spaceship Interface LEDs not switching.

I am a beginner trying to complete the Spaceship Interface tutorial:
https://www.arduino.cc/en/ArduinoStarterKit/Prj02

jpg of circuit in attachments

My code:

/*
Spaceship Interface
*/
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) {
digitalWrite(3, HIGH);
digitalWrite(4, LOW); 
digitalWrite(5, LOW);  
}

else {
digitalWrite(3, LOW); 
digitalWrite(4, LOW); 
digitalWrite(5, HIGH); 

delay(250); // wait for a quarter second
digitalWrite(4, HIGH);
digitalWrite(5, LOW);

delay(250); // wait for a quarter second
}
}

The green LED is supposed to stay on until I press the button, then the green LED will turn off and the two red LEDs will start blinking.
However, nothing happens when I press on the switch (Green LED remains on and red LEDs remain off).

What am I doing wrong?

Remove the wire that is plugged into row 24 of the breadboard. Plug it into the positive power bus around pin 7 to see if that does the trick. If you check the Starter Kit section of the forum you may find other suggestions to help diagnose the problem.

First, welcome to the forums. You will find a lot of people willing to help here.

Photos are rarely useful to diagnosing a problem, but in your case I would strongly recommend buying a set of DuPont jumpers for the breadboard. I am amazed that a learning kit from Arduino wouldn't have more of them than just the red and black ones on the power pins.

It appears that the resistor from the cathode of the first LED is shorting against the anode, but that wouldn't cause the LED to stay on. (It would prevent it from ever working). Be careful with your wiring of a breadboard as shorts are easy. (I would trim the resistor leads a little to make the breadboard a little less of a rat's nest.)

Are you sure the button is positioned correctly? Remember that some of the pins are connected internally:

button2.jpg

button2.jpg

dannable:
Remove the wire that is plugged into row 24 of the breadboard. Plug it into the positive power bus around pin 7 to see if that does the trick. If you check the Starter Kit section of the forum you may find other suggestions to help diagnose the problem.

Just move the wire from row 24 to row 22. If your button is wired incorrectly, this bypasses it altogether.

In my experiance it is not always easy to get those buttons to make proper contact with the breadboard contacts, the pins are not really suitable for breadboard. What dannable suggested will test this.

The code you have only works as intended if you keep your finger on the button, a quick press won't work.