Sketch seems to upload but then AVRdude hangs and Arduino won't respond

So I've been working on a sketch for a good few months now and it is getting rather complex, although compiled it's only 18.4K.

It's been working fine in it's current iteration for ages and last night I made some very minor changes, since then it won't upload.

At first I thought maybe it was running out of RAM so I've commented out loads of strings, and a whopping 2000 element array of unsigned ints, so it's definitely using a lot less RAM than before.

But when I go to upload the sketch, it compiles fine, then I see the TxRx lights flashing away, then when they stop, the progress bar in the IDE stops moving and AVRDude just hangs. The arduino sits there with the pin 13 LED flashing quickly, and an occasional flash n the Rx LED which I'm guessing is AVRdude trying to do something.

If I upload an example sketch everything works fine. I've also tried my sketch on various MEGA2560s and tried uploading it form various computers.

It seems to be my sketch, but nothing has really changed from when it did work, to now when it doesn't. Other than a few lines of mundane code. Unfortunately I don't have a copy of the sketch from when it worked :frowning:

Please help because this epic sketch controls my car and without it I simply can't drive it and I'm stuck lol

Does the sketch have "!!!" anywhere in it?

Like:

Serial.print ("Danger!!!");

So I've been working on a sketch for a good few months now ... Unfortunately I don't have a copy of the sketch from when it worked

Time to learn about source control. Try downloading and installing "git".

Also make some backups from time to time.

Yes is does have a string with !!! and commenting this out solves all my problems!!!

Please explain lol

And yes I realise the values of source control, this started off as a fun little project and grew into something that I now use and rely on. I will be taking much more care in future! Thanks for the advice, I should know better :frowning:

WOW!!! Thanks, I've had the same problem crop up recently and have been debugging for several days now. Reinstalled my drivers. Swapped out several Megas. The program works fine on a UNO. Earlier versions compile, upload and run fine.

This must have been a practical joke someone coded into the compiler for the Mega. I removed the !!! and I'm good to go again. I need a vacation.