/

The Built-in LED on Arduino: A Guide

The Built-in LED on Arduino: A Guide

The Arduino boards come with a useful component known as the built-in LED. This LED is easily identifiable by the letter L located next to it. On the Arduino Uno, you can find it near pin #13, while on the Arduino MKR 1010 WiFi board, it is positioned near the 5V output pin.

In most Arduino boards, this LED is connected to the digital I/O pin #13. However, on certain boards like the Arduino MKR series, it is linked to pin #6. To conveniently reference the exact pin, the LED_BUILTIN constant is available. The Arduino IDE automatically maps this constant to the appropriate pin, depending on the board you are compiling for.

To illuminate the LED, you first need to set the pin as an output in the setup() function using the following code:

1
pinMode(LED_BUILTIN, OUTPUT);

Once the pin is set as an output, you can send a HIGH signal to it using either of these commands:

1
digitalWrite(LED_BUILTIN, HIGH);

or

1
digitalWrite(LED_BUILTIN, 1);

To demonstrate how the built-in LED can be used, let’s consider a simple program that blinks the LED every second:

1
2
3
4
5
6
7
8
9
10
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
digitalWrite(LED_BUILTIN, HIGH);
delay(1000);
digitalWrite(LED_BUILTIN, LOW);
delay(1000);
}

Using this program, the built-in LED will turn on for one second, followed by a one-second pause before turning off and repeating the cycle.

By understanding and utilizing the built-in LED on Arduino boards, you can incorporate visual feedback and add interactive elements to your projects.

tags: [“Arduino”, “built-in LED”, “digital I/O pin”, “LED_BUILTIN”]