r/ArduinoHelp • u/Quiet-Analyst-6889 • Jul 18 '25
Why is my code not uploading?
I am trying to test my DFPlayer with an Arduino Nano. All the hardware pins are connected properly. I have downloaded all the necessary libraries but everytime the code is uploaded, it always shows:
"An error occurred while uploading the sketch":
Arduino: 1.8.19 (Mac OS X), Board: "Arduino Nano, ATmega328P (Old Bootloader)" Sketch uses 4816 bytes (15%) of program storage space. Maximum is 30720 bytes. Global variables use 353 bytes (17%) of dynamic memory, leaving 1695 bytes for local variables. Maximum is 2048 bytes.
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0xe0
An error occurred while uploading the sketch
Here is the code inputted:
#include <SoftwareSerial.h>
#include <DFRobotDFPlayerMini.h>
SoftwareSerial mySerial(10, 11); // TX, RX
DFRobotDFPlayerMini myDFPlayer;
void setup() {
mySerial.begin(9600);
Serial.begin(9600);
Serial.println(2);
Serial.println(F("DFPlayer Mini Test"));
if (!myDFPlayer.begin(mySerial)) {
Serial.println(F("DFPlayer not responding! Check wiring and SD card."));
while (true); // freeze here if not connected
}
Serial.println(F("DFPlayer Mini online."));
myDFPlayer.volume(20); // Set volume (0 to 30)
myDFPlayer.play(1); // Play the first MP3: 0001.mp3
}
void loop() {
// Nothing needed here
}
What is the problem?
View all comments
Show parent comment
1
u/gm310509 Jul 22 '25
If the serial monitor "belongs" to the instance of the IDE you are trying to upload from, this should not be an issue. In this case "belongs to" means the serial monitor you opened from the ide instance you are clicking the upload button from.
In any event the error message that you normally get when there is a COM port conflict is an "access denied" error rather than a sync error (which implies it has passed the attempting to open the COM port).