My code is giving an error avrdude: stk500_recv

Hello, good evening everyone, my name is Lucas and I have a project for glasses for the visually impaired and I need to program my Arduino Nano, could you help me with this? Well, the glasses work as follows, I have an HC-SR04 ultrasonic sensor module with the trig connected to digital port 3 of my Arduino and the echo connected to digital port 4, when this sensor marks a distance of 0 to 100cm it should activate my buzzer, which is on digital port 5 at a frequency of 880hz, this buzzer should be beeping in pulses, the closer to 0cm it should pulse faster, it should also activate my vibration motors, which are on digital port 2, they should be vibrating on pulse as well as my buzzer.
Well, I created my Arduino code and every time I pass it to my Arduino it shows the following error:

avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x57
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x57
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x57
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x57
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x57
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x57
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x57
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x57
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x57
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x57
Failed uploading: uploading error: exit status 1

I'm a bit of a beginner in Arduino so I'm asking for your help to help me fix this problem, below I leave my code

// Defina os pinos para os componentes
const int trigPin = 3;
const int echoPin = 4;
const int buzzerPin = 5;
const int motorPin = 2;

// Defina a frequência do buzzer (880 Hz)
const int buzzerFrequency = 880;

void setup() {
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(buzzerPin, OUTPUT);
  pinMode(motorPin, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  // Mede a distância usando o sensor ultrassônico
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  float duration = pulseIn(echoPin, HIGH);
  float distance = duration * 0.0343 / 2;

  // Ativa o buzzer e os motores com base na distância medida
  if (distance >= 0 && distance <= 100) {
    // Calcula a frequência do buzzer com base na distância
    int buzzerPulse = map(distance, 0, 100, 1000, 100);
    tone(buzzerPin, buzzerFrequency, buzzerPulse);
    digitalWrite(motorPin, HIGH);
  } else {
    noTone(buzzerPin);
    digitalWrite(motorPin, LOW);
  }

  // Exibe a distância no monitor serial
  Serial.print("Distância: ");
  Serial.print(distance);
  Serial.println(" cm");
  delay(100);
}

Hi @veymox. You described the Arduino board you are uploading to as "Nano". Something that can be confusing is there are multiple boards with "Nano" in their name. We need to be certain of exactly which one you have. The reason is that the problem might be caused by the IDE not being correctly configured for your specific board.

Please tell us which of the following boards you are attempting to upload to:

If you aren't sure which one you have, you can provide a picture of the board or a link to the place you bought it from and we'll see if we can identify it.

Hello good evening, I am using nano classic

I'm going to ask you to post the full verbose output from an upload attempt.


:exclamation: This procedure is not intended to solve the problem. The purpose is to gather more information.


Please do this:

  1. Select File > Preferences... (or Arduino IDE > Settings... for macOS users) from the Arduino IDE menus.
    The "Preferences" dialog will open.
  2. Uncheck the box next to Show verbose output during: compilation in the "Preferences" dialog.
  3. Check the box next to Show verbose output during: ☐ upload.
  4. Click the "OK" button.
    The "Preferences" dialog will close.
  5. Attempt an upload, as you did before.
  6. Wait for the upload to fail.
  7. You will see a "Upload error: ..." notification at the bottom right corner of the Arduino IDE window. Click the "COPY ERROR MESSAGES" button on that notification.
  8. Open a forum reply here by clicking the "Reply" button.
  9. Click the <CODE/> icon on the post composer toolbar.
    This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
    Code block icon on toolbar
  10. Press the Ctrl+V keyboard shortcut (Command+V for macOS users).
    This will paste the error output from the upload into the code block.
  11. Move the cursor outside of the code block markup before you add any additional text to your reply.
  12. Click the "Reply" button to post the output.

I've fixed the code tags in your opening post for the upload output..

Code tags for a block are three backticks (```) on their own line, one at the start and one at the end.

Sketch uses 4786 bytes (15%) of program storage space. Maximum is 30720 bytes.
Global variables use 235 bytes (11%) of dynamic memory, leaving 1813 bytes for local variables. Maximum is 2048 bytes.
"C:\Users\Lucas\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\Lucas\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -V -patmega328p -carduino "-PCOM1" -b115200 -D "-Uflash:w:C:\Users\Lucas\AppData\Local\Temp\arduino\sketches\F0BD8C589E4B017D016DE836ECCEF858/sketch_may4a.ino.hex:i"

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\Lucas\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"

         Using Port                    : COM1
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x3b
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x3b
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x3b
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x3b
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x3b
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x3b
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x3b
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x3b
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x3b
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x3b

avrdude done.  Thank you.

Failed uploading: uploading error: exit status 1

This indicates that you're using the "328P" option under tools/processor. You can try the "old bootloader" option under tools/processor and if that fails the "168" option.

If all fail, please provide details

  1. The exact board that you bought (?); a link will do.
  2. Could you upload in the past?
  3. What are the specs of the vibration motors? How are they powered? Have you tried uploading while they are disconnected?

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