If you want to Blink an external LED with this Code using Arduino, you need to build this circuit, where you connect one end of the resistor to the digital pin correspondent to the LED_BUILTIN constant. Connect the long leg of the LED (the positive leg, called the anode) to the other end of the resistor. Connect the short leg of the LED (the negative leg, called the cathode) to the GND. In the diagram below we show a UNO board that has D13 as the LED_BUILTIN value. The value of the resistor in series with the LED may be of a different value than 220 ohms; the LED will lit up also with values up to 470 ohms.



Arduino LED Blink Code
Figure 1: LED connections with Arduino


/*UNCIA ROBOTICS | www.unciarobotics.com
  Turns on and off a light-emitting diode(LED) connected to digital
  13    LED(+)
  GND   LED(-)

void setup() {
  pinMode(13, OUTPUT);    // sets the digital pin 13 as output

void loop() {
  digitalWrite(13, HIGH); // sets the digital pin 13 on
  delay(1000);            // waits for a second
  digitalWrite(13, LOW);  // sets the digital pin 13 off
  delay(1000);            // waits for a second


void setup( )

This function is called when a sketch starts. After that, You can use to initialize variables, pin modes, start using libraries, etc. This function will only run once, after each power-up or reset of the Arduino board.

void loop ( )

This function is called just after calling setup(). As the name suggests this function actively controls the Arduino board by looping consecutively.

pinMode ( )

Description: Configure specific pin to behave either as input or output.

Syntax: pinMode (pin,MODE);

  • pin: the Arduino pin number to set the mode of.

Returns: Nothing

Notes and Warnings:

  • It is only applicable to digital pins.

digitalWrite ( )

Description: Write a HIGH or LOW value to a digital pin.

Syntax: digitalWrite (pin,VALUE);

  • pin: the Arduino pin number.
  • value: HIGH or LOW

Returns: Nothing

Notes and Warnings:

  • It is very important to set pinMode() as OUTPUT first before using digitalWrite() function on that pin.
  • If you do not set the pinMode() to OUTPUT, and connect an LED to a pin, when calling digitalWrite(HIGH), the LED may appear dim.
  • The analog input pins can be used as digital pins, referred to as A0, A1, etc. However, the exception is the Arduino Nano, Pro Mini, and Mini’s A6 and A7 pins, which can only be used as analog inputs.

delay ( )

Description: Pauses the program for the amount of time (in milliseconds) as specified inside the bracket. (1sec = 1000 ms).

Syntax: delay (ms);

  • ms: the number of milliseconds to pause. Allowed data types: unsigned long

Returns: Nothing

Notes and Warnings:

  • While it is easy to use delay function for short pauses in a program, but the use of delay() has significant drawbacks. No other reading of sensors, mathematical calculations, or pin manipulation can go on during the delay function, so in effect. Therefore it brings most other activity to a halt.
  • Certain things do go on while the delay function is controlling the Atmega chip. However, because the delay function does not disable interrupts. Serial communication that appears at the RX pin is recorded, PWM (analogWrite) values and pin states are maintained.


How do I make my LED blink Arduino?

You have to compile the given Program in Arduino IDE and upload it to the Arduino board. If your connections are correct. LED will start Blinking.

How do I increase or decrease the Blinking Frequency/Speed of an LED?

Well for that you have to change the parameter of delay function inside the bracket.

How to identify the Positive(anode) and Negative (cathode) of an LED?

There are two Ways to identify this.

  • Check the legs of an LED. Positive Leg is always longer than the Negative
  • Check the Flags inside the LED. The bigger Flag is Negative and the smaller one is positive.
how to identify positive-anode or negative-cathode in an LED
Still, having doubts?

Ask your questions in comment section below or Contact us.

This Post Has 2 Comments

  1. Ashish Kumar

    Thanks for the information

  2. Vicky

    Great Design !! very helpful

Leave a Reply