The topic has come up several times already here on the board, but has never been answered, so I will describe it again:
I upload a simple program via USB while powering the Arduino board with an external 9V power supply.
The program runs (LED connected to Pin 13 blinks).
I unplug USB. The program still runs, LED continues to blink. Everything fine up to here.
I unplug Power, wait a few seconds.
I plug in the external power supply, the onboard PWR LED lights up, the LED connected to Pin 13 flickrs for maybe a quarter of a second.
Nothing happens. The program does not load, does not start to run.
When I go through the same steps without the external power supply, using USB power instead, the stored program always starts automatically (as would be expected) a few seconds after plugging in USB again.
To rephrase the problem more succinctly: Uploaded programs do not start running when I plug in an external power source. They do start running when using USB as power supply.
Previous topics concerning, but not answering the exact same question:
I have so far tested 3 of our Arduino Boards, will test the rest, but am not very optimistic as it does not seem to be a fluke, but a common problem... and a very inconvenient one, as it makes using the boards away from a computer pretty much impossible.
Do you have any serial commands in your program? My expereince in this case is that the Arduino waits for a signal from the Begin.serial command, and get s hung since it is not connected to the computer.
No, I am not using any serial commands.
This is my code:
int ledPin = 13; // LED connected to digital pin 13
void setup()
{
pinMode(ledPin, OUTPUT); // sets the digital pin as output
}
void loop()
{
digitalWrite(ledPin, HIGH); // sets the LED on
delay(1000); // waits for a second
digitalWrite(ledPin, LOW); // sets the LED off
delay(1000); // waits for a second
}
I have exactly the same problem with a simple circuit : 3 wires from pins 5,6,7 going to a bunch of chained 74hc595 and a led on pin 13.
The board is powered with the 12v output of a PC power supply, the 74hc595 and the rest of the circuit are powered by the 5v output of the same power supply (not by the arduino board).
Sometime (but no always...) the board doesn't start. When I switch on the power supply, the pwr led lights up, the led on pin 13 blinks shortly but nothing else happends then.
At that point if I plug an usb cable to the board with the same jumper setting the program start after 5 seconds.
I've no serial commands in my program and I've tested 3 different boards.
I don't know why but putting a resistor (470h) in-between pin 1 and 2 (rx-tx) seems to solve the problem...
My guess was that the Arduino was waiting for something to happends on the serial port. So I just plugged a resistor from rx to tx. I really don't know if it's a good thing to do but it works.
when the arduino is powered with an external source the USB interface chip is not powered
this leaves the pins 0 and 1 "floating" so when the board is powered on the bootloader is reading garbage from the RX pin and this is stopping it from running your program.
The bootloader normally goes into a timeout after 7 seconds and runs your code.... if the rx pin has garbage this never happens... connecting the pin to ground with a 10k resistor is enough...
Thanks Guillaume and thanks Massimo, now I finally understand the problem. Out of laziness I used Guillaumes solution of simply sticking a 10k Ohm Resistor into Pins 0 and 1 (RX and TX). This works perfectly... Problem solved.