Blink LED in Arduino

Blink LED in Arduino

This article shows the easiest thing you can perform using an Arduino or Genuino to see the output: it blinks the onboard LED also known as -“Hello World of Arduino!”. I hope you have your own Arduino board because that is kind of necessary if you have to blink the LED right? *If not, you can buy Arduino Board and it’s USB cable from here. Here, we are using the built-in LED that most Arduino along with Genuino boards have. This LED is connected to a digital pin-13 in Arduino Uno but its number may differ from board kind to board type. If you want to blink your own LED, you can easily do that too. You just need 220-1000 ohm resistor and an LED. Connect the resistor to the positive terminal of an LED and connect it with any pin you want to. The negative terminal of an LED goes to ground. Here, we are using onboard LED. In case, you need the introduction of an Arduino, refer this article.

The Program

After you are ready with your circuit, connect the Arduino board with your computer and follow these steps:

  • Open Arduino Software
  • Click on Tools–>Port–>Select the Port

Program an Arduino

  • Click on  Tools–>Board–>Arduino Uno

Blink LED Program And now, you are ready to program your Arduino Uno for the first time. Just type the code below.  Don’t copy it!

void setup() 
  pinMode(13, OUTPUT);// selecting the 13th pin as an output pin
void loop() {
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second-value is in milli second-->1000ms equals to 1 sec.
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second

Segments of the Program

In the setup() function, you are going to set up the things which you need only one time to execute. In our case, we need to setup 13th pin as an output pin at the starting of the program. loop() is the function that runs continuously until your microcontroller is on. And that’s what we needed right now. For blinking the LED, we need to turn it on first, then wait for a second, turn it off, and then again wait for the second. digitalWrite() function is doing the exact same thing. You can turn on the LED(YES LED’s GET TURNED ON TOO!), by passing the HIGH argument. the first value is the value of the pon where LED is connected. Similarly, LED get turned off by passing “LOW “argument.

Burning the Program in Arduino

Save the file where you want to. Click on the sketch–> Upload to upload the program to Arduino. And there you go, You have successfully blinked an On-Board LED. Congratulations! *Please note that above-buying link is an affiliate link, so you will be supporting us big time if you buy it from that link.

Leave a Comment

Your email address will not be published. Required fields are marked *

Share This
Scroll to Top