Why do LEDs on pins 8 and 9 flash during upload

I have an Uno with eight LEDs wired to pins 2...9.
As I upload a "null" program
void setup(){}
void loop(){}

I see (in roughly this sequence);

  • The LEDs on pins 8 and 9 flash briefly once simultaneously
  • Flashing on the onboard 'L' LED
  • Flashing on the onboard TX RX LEDs
  • The LEDs on pins 8 and 9 flash briefly once simultaneously

If I now press the "Reset" button only the onboard "L" LED flashes.

With the sketch loaded when I plug in the USB I see;

  • The LEDs on pins 8 and 9 flash briefly once simultaneously
  • Flashing on the onboard 'L' LED

Why do the LEDs on pins 8 and 9 flash once during power-up and twice during uploading (once at the start of upload and once at the end)?

I have no idea why 8 and 9 flash.

I would guess that the Bootloader flashes 13, just to show its installed.

@Si: You have confirmed that pins 8 and 9 flash an attached LED when the bootloader runs?

@coding - no I haven't. Just taking radman at his word.

The bootloader (at least ATmegaBOOT_168.c) initializes the port B to blink the LED (pin 13). As the LED is on PB5, and pins 8 and 9 are on PB0 and PB1, this initialization apparantly makes those pins low for a short while. Pins 10, 11 and 12 could react the same. The pins 2 to 7 are on port D, so are not affected.

I think my circuit was correct because it operated the LEDs the way I was expecting, apart from the brief flashes during upload.

I have now just got LEDs on pins 8, 9 and 3 and I still get the same flashing on upload.
However if I remove the LED from pin 3 I no-longer get the flashing.

The circuit is 3 x LEDs and 3 x 560ohm resistors.
Pins 8, 9 and 3 each go to the +Ve of a separate LED.
The -Ve of the LEDs go through a resistor to GND.

This is as per the CIRC-02 diagram I got as part of the kit.
Everything is well spaced, and there are no obvious faults.

If somebody could reproduce the same thing on an UNO that would be good.
I don't have an electronics background, and am only just starting to explore the Arduino, so I would be grateful if any explanations did not assume any knowledge.

I noticed another post "Brief digital high on startup" that appears to describe something similar on another board.

This is the source of the blink...
http://arduino.cc/forum/index.php/topic,64256.0.html

If I now press the "Reset" button only the onboard "L" LED flashes.

...is the test that divides the problem between the board / bootloader and your circuit. Because the circuit behaves correctly when you press the reset button, the problem has to be with the board or the bootloader. In this case, the problem is with the board (the auto-reset circuit).

Hello Coding Badly. Thanks for identifying the problem as being the board, it is nice to know there is an explanation for what was happening. As I am only experimenting its not a big issue for me, but I can see how it could cause problems for others.