Project02 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); //green
digitalWrite(4,LOW);
digitalWrite(5,LOW);

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

delay(250); // ms

digitalWrite(4,HIGH);
digitalWrite(5,LOW );

delay(250);

}
}

Can anyone tell me why my circuit doesn’t work? It just blinks the 2 red light.

Hi.

Please read How to use this forum (click !), and its links.

466040d2d75b209bd07b18133437eb503bea5027.jpg

7208d0efff35b4c86fc217fd92ce8f44aeacb571.jpg

54be62973b8f6de82d4a13dfddcf7cc47156af8c.jpg

I’m wondering if that switch of yours is mounted in the correct orientation.
So try what happens if you:
Either rotate that switch 90 degrees, or make a connection between breadboard pins h21 and h23.
Then see what it does.

Nope, nothing happens. It looks like my switch state is never zero.

if (switchState = LOW) // make switchState low

if (switchState == LOW) // test if switchState is low

Leo..

thank you so much.. damn I made a silly mistake in the code.