Arduino Spaceship Interface Code

Im on the 2nd project of arduino starter kit and i dont understand whats wrong with my code.
Everything is done exactly like the book in the circuit
This is my CODE:

int switchState = 0;

void setup() {
// put your setup code here, to run once:
pinMode(3 , OUTPUT);
pinMode(4 , OUTPUT);
pinMode(5 , OUTPUT);
pinMode(2 , INPUT);

}

void loop() {
// put your main code here, to run repeatedly:
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);
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
delay(250);
}
}

Thank you for you help and attention

There doesn't appear to be anything obviously wrong with your code. What makes you think there is?

Try this
pinMode(2 , INPUT_PULLUP); // turns on internal pullup resistor.

dannable:
There doesn't appear to be anything obviously wrong with your code. What makes you think there is?

Because when it gives me an error

CrossRoads:
Try this
pinMode(2 , INPUT_PULLUP); // turns on internal pullup resistor.

Arduino: 1.6.3 (Windows 7), Placa:"Arduino Uno"

sketch_may06a.cpp.o: In function `loop':

C:\Program Files (x86)\Arduino/sketch_may06a.ino:32: undefined reference to `delay'

C:\Program Files (x86)\Arduino/sketch_may06a.ino:35: undefined reference to `delay'

C:\Users\casa\AppData\Local\Temp\build3596501948761043943.tmp/core.a(main.cpp.o): In function `main':

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/main.cpp:32: undefined reference to `init'

collect2.exe: error: ld returned 1 exit status

Erro ao compilar.

sketch_may06a.cpp.o: In function `loop':

C:\Program Files (x86)\Arduino/sketch_may06a.ino:32: undefined reference to `delay'

C:\Program Files (x86)\Arduino/sketch_may06a.ino:35: undefined reference to `delay'

C:\Users\casa\AppData\Local\Temp\build3596501948761043943.tmp/core.a(main.cpp.o): In function `main':

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/main.cpp:32: undefined reference to `init'

collect2.exe: error: ld returned 1 exit status

Erro ao compilar.

Este relatório teria mais informação com
"Mostrar output verboso durante a compilação"
ativo em Ficheiro > Preferências

That looks like a failed install then.

CrossRoads:
That looks like a failed install then.

Thank you so much.
I feel so dumb now.
Seriously aprettiated bro. :slight_smile:

wydtron:
Arduino: 1.6.3 (Windows 7), Placa:"Arduino Uno"

sketch_may06a.cpp.o: In function `loop':

C:\Program Files (x86)\Arduino/sketch_may06a.ino:32: undefined reference to `delay'

C:\Program Files (x86)\Arduino/sketch_may06a.ino:35: undefined reference to `delay'

C:\Users\casa\AppData\Local\Temp\build3596501948761043943.tmp/core.a(main.cpp.o): In function `main':

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/main.cpp:32: undefined reference to `init'

collect2.exe: error: ld returned 1 exit status

Erro ao compilar.

sketch_may06a.cpp.o: In function `loop':

C:\Program Files (x86)\Arduino/sketch_may06a.ino:32: undefined reference to `delay'

C:\Program Files (x86)\Arduino/sketch_may06a.ino:35: undefined reference to `delay'

C:\Users\casa\AppData\Local\Temp\build3596501948761043943.tmp/core.a(main.cpp.o): In function `main':

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/main.cpp:32: undefined reference to `init'

collect2.exe: error: ld returned 1 exit status

Erro ao compilar.

Este relatório teria mais informação com
"Mostrar output verboso durante a compilação"
ativo em Ficheiro > Preferências

happened to me too, just re-install :slight_smile: