14

(I have a Sparkfun RedBoard, but this question seems to apply to R3 Unos and Uno-compatible boards.) As I was building the first circuit in my SIK guidebook (add a resistor, LED, hook it up and make it blink from code), I noticed a blue LED on the board itself did everything that the circuit's LED did - blinking according to the programming.

Why is this LED here? What use cases is it for?

What kind of circuits will I have to adjust to account for this LED?

Is pin 13 traditionally a debug or a troubleshooting pin? Where did this convention come from?

1
  • 2
    Why is there a scroll wheel on a mouse? It's convenient, but not needed. May 8, 2014 at 0:52

4 Answers 4

11

The LED on pin 13 is used by the optiboot loader (the one used on UNO):

  • at Arduino boot time (the LED blinks a few times)
  • when uploading a sketch to Arduino

I haven't checked other bootloaders, they may provide the same behavior as the optiboot.

For optiboot, there are optional defines (at compile time) to modify this behavior:

  • LED_START_FLASHES defines the number of flashes of pin 13 LED at boot time (can be set to 0)
  • LED_DATA_FLASH will use pin 13 LED during sketch upload if defined at compile-time

These defines are explained in hardware/arduino/bootloaders/optiboot/optiboot.c from within your Arduino IDE install directory.

If you want to change these, you will have to recompile the optiboot loader first and then burn it to your Arduino through an ISP programmer.

I guess one other reason for the LED on pin 13 was to simplify the demonstration of the "Hello World" sketch for Arduino, namely the Blink sketch, without the need for any extra component.

10

What kind of circuits will I have to adjust to account for this LED?

You'll need to take it into account if you're using that pin as a digital input.

NOTE: Digital pin 13 is harder to use as a digital input than the other digital pins because it has an LED and resistor attached to it that's soldered to the board on most boards. If you enable its internal 20k pull-up resistor, it will hang at around 1.7V instead of the expected 5V because the onboard LED and series resistor pull the voltage level down, meaning it always returns LOW. If you must use pin 13 as a digital input, set its pinMode() to INPUT and use an external pull down resistor. Arduino - DigitalPins

1
  • 1
    I just ran into this problem while using a 1wire temperature sensor. I couldn't enumerate the bus due to that LED interfering. I noticed some odd spikes on my oscilloscope when using that pin. I moved to another pin and all was good. Jan 21, 2017 at 19:27
4

What everyone else said, plus: if you find the digital-13 LED gives you a problem, you can always remove it from the circuit, either by removing the LED, or the series resistor.

This might be useful if you are running out of digital I/Os, or you want several contiguous I/O bits and don't want one of them to behave differently from the others.

1

Yes, pin 13 is traditionally an output pin that drives an LED. But the blue LED should not be blinking as it is the "power on" indicator - do you have a grunty power supply to your board?

You can experiment with PWM to the pin13 LED, which will control its apparent brightness. There are plenty of example sketches on the web.

2
  • I don't know what a grunty power supply is; power was supplied via USB. It looks like RedBoards are pre-programmed with the Blink sketch, which uses pin 13.
    – KatieK
    May 8, 2014 at 16:36
  • "Grunty". LOL. I think he means a very high current power supply. I use the term "stiff", meaning it resists voltage droop at higher loads.
    – Duncan C
    Mar 1, 2019 at 19:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.