Arduino Blocks at Uploading
There is a bug in early versions of the Mega2560 bootloader.  It crashes on !!! (or enters some other special state that stops uploading happening).

Your string that contains !!! will be breaking it:

Serial.println("Ended !!!");


Simple solution: don't use so many exclamation marks.