Re: Arduino Mega 2560 R3
just recently, I put 2 and 2 together and determined the same problem you have that happens to me now and then, no rhyme or reasoning to timing it seemed, was in fact the loaded sketches that use digital ports 0, and 1 and if the sketch loaded in the arduino (you know how they run as soon as any power up) if the program happens to be machine-gunning bits out the ports constantly as it runs, uploading new sketches can flake out just as described...or be hit and miss roulette.
I figured out by pulling digital 0, 1 plus any other digital I/O lines for that matter before uploading, makes a world of difference.
Yellow LEDs make their high speed frenetic wiggle like we expect, lol.
This may or may not be the solution in your case, but something wise to know, because 'it does happen' either way.
AMSAT terrestrial loc - (grid square) EM-12
wings are for fairies, and runways are for fashion models!