I\'ve uploaded a sketch to an Arduino Uno whose loop is something like this:
void loop(){
Serial.println(\"Hello, World!\");
}
So, now,
If the port says Already used, then you are probably using the wrong port.
Switch it to the port where you connected your Arduino and then try to re-upload, you will definitely see it work.
Try the following:
There is a delay before the boot loader starts the programs, just work on your timing. It worked for me when a bug in my Arduino's code was executing a soft reset every 500 ms.
I got a similar problem.
If I power on my Arduino, there is a delay before the uploaded program execute.
So I use that delay for uploading new program, or empty program:
void setup(){}
void loop(){}
So my problem was solved.
Unplug any connection to Arduino pins before upload.
Arduino Leonardo board:
I had the very same problem today. Here is a simple solution we found to solve this issue (thanks to Anghiara):
Instead of loading your new code to the Arduino using the "upload button" (the circle with the green arrow) in your screen, use your mouse to click "Sketch" and then "Upload".
Please remember to add a delay() line to your code when working with Serial.println() and loops. I learned my lesson the hard way.
Here's what I did in Linux to be able to program my Arduino Micro which was stuck in a loop sending the 0 key when connected by USB;
# while true; do xinput float $(xinput --list | grep -i Arduino | awk '{print $7}' | cut -d'=' -f 2); done
Your output might be slightly different so just try running;
# watch xinput --list
then plug in the Arduino and see how the output is formatted.
This stopped X from accepting the keypresses and allowed the Arduino IDE to program finally!