Can an Arduino be coded to run a sketch when plugged into any USB port?

Robin2:
What you say in Reply #11 seems correct.

I suspect this is a Leonardo issue that you would not see with an Uno or Mega.

The way to reset a Leonardo is to open the serial port at 1200 baud and then close it again. Then use your chosen baud rate. This is probably on the Leonardo product page.

...R

Same problem with the Mega, just sat waiting for the Arduino.