I can't upload the new code

I cannot upload the code to my Arduino mega 2560 but my last code is still working if I upload other code it telling my uploading after some 2min it showing time out error

raise your issue on support@arduino.cc

(deleted)

I connected an i²c 20*4 LCD display to my Arduino mega I tried to change the wire , changing the port, changing the laptop,
Even though it worked perfectly fine with me I connected many sensor joystick everything worked perfectly fine but suddenly the last uploaded LCD code was strucked I can't upload anything to it
It keeps telling me uploading after 1 min it tell time out error
It works with my other Arduino
What can I do??

Please do this:

  • (In the Arduino IDE) File > Preferences
  • Uncheck the checkbox next to "Show verbose output during: compilation"
  • Check the checkbox next to "Show verbose output during: upload
  • Click "OK"
  • Sketch > Upload
  • After the upload fails, you'll see a button on the right side of the orange bar "Copy error messages" (or the icon that looks like two pieces of paper at the top right corner of the black console window in the Arduino Web Editor). Click that button.
  • In a forum reply here, click on the reply field.
  • Click the </> button on the forum toolbar. This will add the forum's code tags markup to your reply.
  • Press "Ctrl + V". This will paste the upload output between the code tags.
  • Move the cursor outside of the code tags before you add any additional text to your reply.
[/coArduino: 1.8.9 (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

Sketch uses 6794 bytes (2%) of program storage space. Maximum is 253952 bytes.
Global variables use 440 bytes (5%) of dynamic memory, leaving 7752 bytes for local variables. Maximum is 8192 bytes.
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
An error occurred while uploading the sketch

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






i use this many time but suddenly it is happened

Does the problem still occur if you detach the LCD and all other external components/shields/etc. from the Mega?

yes

Make sure you have selected the port of your Arduino board from the Tools > Port menu.

Sometimes the port will be labeled with the board name in the menu. Other times it will not. If you don’t know which port is your Arduino, you can find it like this:

  • Unplug your Arduino board from the computer.
  • Tools > Port
  • Note the ports, if any, listed in the menu.
  • Close the Tools menu
  • Plug your Arduino board into the computer.
  • Tools > Port - The new port listed in the menu is your Arduino board.

yeah i have done it even though it is not uploading

(deleted)


int redPin= 7;
int greenPin = 5;
int bluePin = 3;
void setup() {
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
}
void loop() {

setColor(255, 0, 0); // White Color
delay(10);
setColor(0, 255, 0); // White Color
delay(10);
setColor(0,0,255);
delay(10);
}
void setColor(int redValue, int greenValue, int blueValue) {
analogWrite(redPin, redValue);
analogWrite(greenPin, greenValue);
analogWrite(bluePin, blueValue);
}

this my code it worked perfectly fine

suddenly it is not uploading

even though it is working fine with my uno

i tried to upload even blink code it is not uploading

same issue

The final thing you can try is burning the bootloader to your Mega. You will need an ISP programmer for this. If you don't have an ISP programmer, you can use a spare Arduino board as an "Arduino as ISP":

I tried it not uploading same problem
But it deleted my older code

It sounds like you must have damaged something on your Mega. I recommend just buying another one.