Go Down

Topic: Arduino Spaceship Interface Code (Read 4290 times) previous topic - next topic

wydtron

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

dannable

There doesn't appear to be anything obviously wrong with your code. What makes you think there is?
Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

CrossRoads

Try this
pinMode(2 , INPUT_PULLUP); // turns on internal pullup resistor.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

wydtron

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

wydtron

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

CrossRoads

That looks like a failed install then.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

wydtron

That looks like a failed install then.
Thank you so much.
I feel so dumb now.
Seriously aprettiated bro. :)

janvier123

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 :)

Go Up