What is this error message and why am I getting it?

C:\Users\203310\AppData\Local\Temp\ccakTOvO.ltrans0.ltrans.o: In function main': C:\Users\203310\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/main.cpp:46: undefined reference to loop'
collect2.exe: error: ld returned 1 exit status

exit status 1

Compilation error: exit status 1

I keep getting this error message when trying to upload to a (genuine) Uno.

Here is my code:

`#include <Servo.h>`
`Servo myservo;  // create servo object to control a servo`

`void setup() {`
  `myservo.attach(9);  // attaches the servo on pin 9 to the servo object`
  `delay(100);`
  `myservo.write(0);                  // sets the servo position` 
  `delay(100);                           // waits for the servo to get there`
  `myservo.write(90);                  // sets the servo position`
  `delay(5000);                           // waits for the servo to get there`
  `myservo.write(0);                  // sets the servo position`

I hope I formatted the code correctly.
Thanks.

you did not but nice attempt :slight_smile:

and if it's all the code then you are missing some stuff like the closing brace and the loop() function definition

this would compile

#include <Servo.h>
Servo myservo;  // create servo object to control a servo

void setup() {
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
  delay(100);         // waits for the servo to get there
  myservo.write(0);   // sets the servo position
  delay(100);         // waits for the servo to get there
  myservo.write(90);  // sets the servo position
  delay(5000);        // waits for the servo to get there
  myservo.write(0);   // sets the servo position
}

void loop() {}

(read How to get the best out of this forum to see how to use the code tags and more)

You do not have a loop() function in your sketch. Such a function is mandatory in an Arduino sketch even if the function does nothing

Your topic has been moved to a more suitable location on the forum.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.