Help uploading my code

Arduino: 1.8.18 (Windows 10), Board: "Arduino Nano, ATmega328P "

Sketch uses 8444 bytes (27%) of program storage space. Maximum is 30720 bytes.

Global variables use 460 bytes (22%) of dynamic memory, leaving 1588 bytes for local variables. Maximum is 2048 bytes.

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xd3

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0xd3

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0xd3

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0xd3

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0xd3

Problem uploading to board. See https://support.arduino.cc/hc/en-us/sections/360003198300 for suggestions.

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0xd3

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0xd3

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0xd3

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0xd3

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0xd3

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

the code

// Include Libraries
#include "Arduino.h"
#include "BTHC05.h"
#include "Buzzer.h"
#include "DCMDriverL298.h"
#include "NewPing.h"
#include "Servo.h"

// Pin Definitions
#define BTHC05_PIN_TXD 11
#define BTHC05_PIN_RXD 10
#define BUZZER_PIN_SIG 2
#define DCMOTORDRIVERL298_PIN_INT1 4
#define DCMOTORDRIVERL298_PIN_ENB 5
#define DCMOTORDRIVERL298_PIN_INT2 6
#define DCMOTORDRIVERL298_PIN_ENA 3
#define DCMOTORDRIVERL298_PIN_INT3 7
#define DCMOTORDRIVERL298_PIN_INT4 8
#define HCSR04_PIN_TRIG 12
#define HCSR04_PIN_ECHO 9
#define SERVO9G_PIN_SIG 13

// Global variables and defines
const int servo9gRestPosition = 20; //Starting position
const int servo9gTargetPosition = 150; //Position when event is detected
// object initialization
BTHC05 bthc05(BTHC05_PIN_RXD,BTHC05_PIN_TXD);
Buzzer buzzer(BUZZER_PIN_SIG);
DCMDriverL298 dcMotorDriverL298(DCMOTORDRIVERL298_PIN_ENA,DCMOTORDRIVERL298_PIN_INT1,DCMOTORDRIVERL298_PIN_INT2,DCMOTORDRIVERL298_PIN_ENB,DCMOTORDRIVERL298_PIN_INT3,DCMOTORDRIVERL298_PIN_INT4);
NewPing hcsr04(HCSR04_PIN_TRIG,HCSR04_PIN_ECHO);
Servo servo9g;

// define vars for testing menu
const int timeout = 10000; //define timeout of 10 sec
char menuOption = 0;
long time0;

// Setup the essentials for your circuit to work. It runs first every time your circuit is powered with electricity.
void setup()
{
// Setup Serial which is useful for debugging
// Use the Serial Monitor to view printed messages
Serial.begin(9600);
while (!Serial) ; // wait for serial port to connect. Needed for native USB
Serial.println("start");

bthc05.begin(9600);
//This example uses HC-05 Bluetooth to communicate with an Android device.
//Download bluetooth terminal from google play store, https://play.google.com/store/apps/details?id=Qwerty.BluetoothTerminal&hl=en
//Pair and connect to 'HC-05', the default password for connection is '1234'.
//You should see this message from your arduino on your android device
bthc05.println("Bluetooth On....");
servo9g.attach(SERVO9G_PIN_SIG);
servo9g.write(servo9gRestPosition);
delay(100);
servo9g.detach();
menuOption = menu();

}

// Main logic of your circuit. It defines the interaction between the components you selected. After setup, it runs over and over again, in an eternal loop.
void loop()
{

if(menuOption == '1') {
// HC - 05 Bluetooth Serial Module - Test Code
String bthc05Str = "";
//Receive String from bluetooth device
if (bthc05.available())
{
//Read a complete line from bluetooth terminal
bthc05Str = bthc05.readStringUntil('\n');
// Print raw data to serial monitor
Serial.print("BT Raw Data: ");
Serial.println(bthc05Str);
}
//Send sensor data to Bluetooth device  
bthc05.println("PUT YOUR SENSOR DATA HERE");
}
else if(menuOption == '2') {
// Buzzer - Test Code
// The buzzer will turn on and off for 500ms (0.5 sec)
buzzer.on();       // 1. turns on
delay(500);             // 2. waits 500 milliseconds (0.5 sec). Change the value in the brackets (500) for a longer or shorter delay in milliseconds.
buzzer.off();      // 3. turns off.
delay(500);             // 4. waits 500 milliseconds (0.5 sec). Change the value in the brackets (500) for a longer or shorter delay in milliseconds.
}
else if(menuOption == '3') {
// L298N Motor Driver with Dual Hobby DC motors - Test Code
//Start both motors. note that rotation direction is determined by the motors connection to the driver.
//You can change the speed by setting a value between 0-255, and set the direction by changing between 1 and 0.
dcMotorDriverL298.setMotorA(200,1);
dcMotorDriverL298.setMotorB(200,0);
delay(2000);
//Stop both motors
dcMotorDriverL298.stopMotors();
delay(2000);

}
else if(menuOption == '4') {
// Ultrasonic Sensor - HC-SR04 - Test Code
// Read distance measurment from UltraSonic sensor           
int hcsr04Dist = hcsr04.ping_cm();
delay(10);
Serial.print(F("Distance: ")); Serial.print(hcsr04Dist); Serial.println(F("[cm]"));

}
else if(menuOption == '5') {
// 9G Micro Servo - Test Code
// The servo will rotate to target position and back to resting position with an interval of 500 milliseconds (0.5 seconds) 
servo9g.attach(SERVO9G_PIN_SIG);         // 1. attach the servo to correct pin to control it.
servo9g.write(servo9gTargetPosition);  // 2. turns servo to target position. Modify target position by modifying the 'ServoTargetPosition' definition above.
delay(500);                              // 3. waits 500 milliseconds (0.5 sec). change the value in the brackets (500) for a longer or shorter delay in milliseconds.
servo9g.write(servo9gRestPosition);    // 4. turns servo back to rest position. Modify initial position by modifying the 'ServoRestPosition' definition above.
delay(500);                              // 5. waits 500 milliseconds (0.5 sec). change the value in the brackets (500) for a longer or shorter delay in milliseconds.
servo9g.detach();                    // 6. release the servo to conserve power. When detached the servo will NOT hold it's position under stress.
}

if (millis() - time0 > timeout)
{
    menuOption = menu();
}

}

// Menu function for selecting the components to be tested
// Follow serial monitor for instrcutions
char menu()
{

Serial.println(F("\nWhich component would you like to test?"));
Serial.println(F("(1) HC - 05 Bluetooth Serial Module"));
Serial.println(F("(2) Buzzer"));
Serial.println(F("(3) L298N Motor Driver with Dual Hobby DC motors"));
Serial.println(F("(4) Ultrasonic Sensor - HC-SR04"));
Serial.println(F("(5) 9G Micro Servo"));
Serial.println(F("(menu) send anything else or press on board reset button\n"));
while (!Serial.available());

// Read data from serial monitor if received
while (Serial.available()) 
{
    char c = Serial.read();
    if (isAlphaNumeric(c)) 
    {   
        
        if(c == '1') 
			Serial.println(F("Now Testing HC - 05 Bluetooth Serial Module"));
		else if(c == '2') 
			Serial.println(F("Now Testing Buzzer"));
		else if(c == '3') 
			Serial.println(F("Now Testing L298N Motor Driver with Dual Hobby DC motors"));
		else if(c == '4') 
			Serial.println(F("Now Testing Ultrasonic Sensor - HC-SR04"));
		else if(c == '5') 
			Serial.println(F("Now Testing 9G Micro Servo"));
        else
        {
            Serial.println(F("illegal input!"));
            return 0;
        }
        time0 = millis();
        return c;
    }
}

}

Programmer is not responding!
There is no communication with the board!

Hi @aloulo22.

Please try this experiment and report the results:


:exclamation: This will not solve the problem. The experiment is done to gather more information about the problem.


  1. Connect the Arduino board to your computer with the USB cable.
  2. Press and release the button on the Arduino board that is marked "RESET".

Now please reply with the answers to the following questions:

  • Did you see the LED marked "L" on the board blink immediately after you released the "RESET" button?
  • Did the LED blink only once, or did it blink multiple times?

Did it ever work? If not, have you tried the different options under tools -> processor. For clone Nanos, the old bootloader is the option that usually works.

If it worked before what was all connected when it started failing?

Please provide a link to the board that you bought.

Please edit your post with the code and apply code tags ad described in How to get the best out of this forum.

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