Upload error skt 500_recv(): programmer is not responding - stk500_getsync()

So, I am using a Mac and an Arduino UNO

I have a very simple code to activate a motor continuously. for this I used this code with the accelstepper library

/*Example sketch to control a stepper motor with DRV8825 stepper motor driver AccelStepper library and Arduino. More info: https://www.makerguides.com */
#include <AccelStepper.h>
//Define stepper motor connections
#define dirPin 2
#define stepPin 3
//Create stepper object
AccelStepper stepper(1,stepPin,dirPin); //motor interface type must be set to 1 when using a driver.
void setup()
  stepper.setMaxSpeed(1000); //maximum steps per second

void loop()
  stepper.setSpeed(400); //steps per second
  stepper.runSpeed(); //step the motor with constant speed as set by setSpeed()

I ve been able to upload the code without issue and everythink worked fine.

When I tried to reupload the code after a few testing to reduce the rotation speed, I had this error message

avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00

I have tried several time with always the same result.
At one point I changed adruino board and I was able to upload the code with the new motor speed.

Later on when I wanted again a different speed ; and again : impossible to upload the code to one of the two boards that already each have the code mentioned earlier. Both board still work and can make my motor rotate (each at a different speed) but none of them is allowing a new upload. with the same exact error message again…

I bough a third board and it worked: .i could upload my third code with the third speed…

How can I fix this error and stop buying new board everytime I want a different speed tested :slight_smile: ??
stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt x of 10

thank you for your help

Try this:

Sketch > Upload

Watch the black console window at the bottom of the Arduino IDE window. As soon as you see something like this:

Sketch uses 1596 bytes (4%) of program storage space. Maximum is 32256 bytes.
Global variables use 184 bytes (8%) of dynamic memory, leaving 1864 bytes for local variables. Maximum is 2048 bytes.

press and release the reset button on your Uno.

Does the upload finish successfully after doing that?