Turn on LED Arduino Basic Tutorial

Posted on

Arduino Basic Tutorial

Controlling Arduino’s Internal LEDs – This is an article made especially for those of you who are beginners in playing Arduino based on the ATMega328 microcontroller.

By default, Arduino boards have an internal LED. This LED is connected to PIN 13. So we will try to make this pin 13 output HIGH and LOW voltages for one second.

In theory, the voltage with a logic HIGH is 5 Volts and a logic LOW is 0 Volts.

But in practice, not all logic HIGH is 5 Volts, it could be 4, 4.5 or 4.8 Volts. But in the microcontroller, the logic still reads HIGH.

Turn on LED Arduino
Arduino Uno Internal LED (image from SparkFun Electronics – Juan Peña)

Turn On Internal LED Arduino

Now please connect Arduino to your PC, then open Arduino IDE and follow these steps:

  • Go to menu File > Examples > 0.1 Basics > Blink
  • Then you will see a program like this:

  Turns an LED on for one second, then off for one second, repeatedly.

  Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
  it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
  the correct LED pin independent of which board is used.
  If you want to know what pin the on-board LED is connected to on your Arduino
  model, check the Technical Specs of your board at:

  modified 8 May 2014
  by Scott Fitzgerald
  modified 2 Sep 2016
  by Arturo Guadalupi
  modified 8 Sep 2016
  by Colby Newman

  This example code is in the public domain.


// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
  • Please click the Tools menu > Board.
  • Select the Arduino/Genuino Uno list.
  • Select your Arduino USB Port.
  • Select AVRISP Programmer mkll.
  • Then return to the menu, click Upload as shown in the image below
Turn on LED Arduino
  • If you have finished the upload process, pay attention to the LED on your Arduino, then you will see the LED turn on in approximately 1 second.
  • This 1 second timing is determined by the value of delay(1000). If you want the LEDs to flash alternately within 2 seconds, change delay to delay(2000).

Turn On LED External Arduino

In real projects, we rarely use the internal LED. We will use the External LED more often, because we can change the position of the LED. For the circuit, please look at the following image.

Turn on LED Arduino

We use a resistor with a value of 330 Ohms. Why do we use a resistor? For more, please read the article How to choose the correct Resistor For LED.

Please follow the steps from Turning on the Internal LED and upload the program to Arduino, then take a look at your Arduino. If the external LED is on, you have successfully assembled it. If it doesn’t light up, check the circuit again.

I hope this tutorial can be useful.

Leave a Reply