Arduino Forum

Products => The Arduino Starter Kit and Basic Kit => Topic started by: wydtron on May 06, 2015, 02:07 pm

Title: Arduino Spaceship Interface Code
Post by: wydtron on May 06, 2015, 02:07 pm
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
Title: Re: Arduino Spaceship Interface Code
Post by: dannable on May 06, 2015, 02:55 pm
There doesn't appear to be anything obviously wrong with your code. What makes you think there is?
Title: Re: Arduino Spaceship Interface Code
Post by: CrossRoads on May 06, 2015, 03:02 pm
Try this
pinMode(2 , INPUT_PULLUP); // turns on internal pullup resistor.
Title: Re: Arduino Spaceship Interface Code
Post by: wydtron on May 06, 2015, 03:06 pm
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
Title: Re: Arduino Spaceship Interface Code
Post by: wydtron on May 06, 2015, 03:10 pm
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
Title: Re: Arduino Spaceship Interface Code
Post by: CrossRoads on May 06, 2015, 03:16 pm
That looks like a failed install then.
Title: Re: Arduino Spaceship Interface Code
Post by: wydtron on May 06, 2015, 03:42 pm
That looks like a failed install then.
Thank you so much.
I feel so dumb now.
Seriously aprettiated bro. :)
Title: Re: Arduino Spaceship Interface Code
Post by: janvier123 on May 13, 2015, 07:31 am
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 :)