Avrdude error on Arduino UNO related to servo

So the thing happening is that when uploading a simple sketch to Arduino UNO it works. The BMP280 test example works too. But, when I upload a sketch for servo(9g servo) rotation it shows avrdude error.

The error I am getting:

avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00

My code:

#include <Servo.h>

Servo yaxis;
Servo xaxis;

void setup() {
  yaxis.attach(3);
  xaxis.attach(2);
  }
void loop() {
  yaxis.write(180);
  xaxis.write(180);
  delay(1000);

  yaxis.write(0);
  xaxis.write(0);
  delay(1000);

}

Does the problem still happen when you disconnect the servos completely before the upload?

How do you power the servos?
Which servos? What are the specifications?

I will try opening the servos and then upload.
I am using 9g servos

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