LED blinking automatically by itself

My LED starts blinking as soon as I plug in the USB cable, before I have even started the Arduino program, let alone run the Digital Blink code. Is this normal or is the board defective?

Hmm, once I run the Arduino program, the blinking stops.

The bootloader includes the blink program when it's freshly installed on the Arduino. This will be replaced as soon as you load another program.

Also remember that when a pin isn't configured be an output, it won't be driven to a specific state by the micro. That means electrical noise can cause the LED on pin 13 to appear likes it's flashing randomly.

If you don't want it to toggle, pinMode(13, OUTPUT); digitalWrite(13, LOW);

That means electrical noise can cause the LED on pin 13 to appear likes it's flashing randomly.

I'm pretty sure this isn't true. When a pin is designated as an input, it has very high impedance and will only sink or source on the order of a few microamps. The voltage on the pin will just be pulled up or down by the LED (electrical noise will not be capable of lighting the LED while the pin is high-Z). Of course the LED will glow faintly if you enable the input's internal pull-up and the other side of the LED is tied to ground. The internal pull-up ties the input to Vcc through a 30k internal resistor, which allows enough current to pass to make most LEDs light at least a little bit.

  • Ben

Again, the important take away is, when a pin isn’t configured be an output, it won’t be driven to a specific state by the micro.

If you want the LED to be off, then you should do so in your code, or attach a pull down resistor to GND on that pin.

Also it’s worth mentioning that if you have another device connected to Digital pin 13 (maybe a serial TX) then you may also see the LED lit.

it won't be driven to a specific state by the micro.

I agree that this is an important point, but it is also important to note that a high-Z pin will not by itself be capable of driving anything, even if there is electrical noise. It will, however, be capable of pulling another high-impendance input to random voltages at the whim of electrical noise. It is completely adequate to turn an LED off by setting its pin as a high-Z input even with no pull-down on the line, assuming there is nothing else on the line capable of driving it.

  • Ben