Blinking a Simple LED using Arduino Uno

Blinking an LED using an Arduino is quite simple.

Make the following connections and connect the Arduino to the computer via the USB cable:

1. Blink LED.jpg

These connections result in the following equivalent schematic:

1. Blink LED Schematic.jpg

Now open the Arduino IDE, and write the following code:

int ledPin=8;

void setup()

void loop()

Explanation of each line of the code:

int ledPin=8;

This statement initializes the integer variable ledPin as 8

void setup(){ }

This statement is the first statement of the program that is run (or executed) and sets up certain basic input output (and other as required) characteristics (whatever is inside the curly braces – i.e. whatever we next write inside the function setup() ) of the program on the board (note that in the actual code, the curly braces are not empty). This statement is executed just once – every time the reset button on the board (the big red/orange button on the Arduino Uno) is pressed.

This statement (which is inside the function setup()) designates the ledPin (which we had earlier set to 8, so it will act upon pin 8 – that is how the function pinMode has been predefined) as OUTPUT pin i.e. it will output current and voltage.

void loop(){ }

Everything inside this function (i.e. within the curly braces – which are not empty in the actual code) runs on an infinite loop


This statement tells the board to start outputting 5V via ledPin (i.e. pin 8, as set previously). Note that there are two conditions for pin 8 – HIGH (5v) and LOW(0V).


This statement tells the board to continue the ongoing operation (i.e. outputting 5V via pin 8) for 250 milliseconds


This statement tells the board to start outputting 0V via ledPin (i.e. pin 8, as set previously).


This statement tells the board to continue the ongoing operation (i.e. 0V via pin 8) for 1000 milliseconds (= 1 second).

Finally, upload the code by clicking on the Upload button on the IDE:

1. Blink LED IDE Screenshot.jpg

It will compile the sketch(i.e. the code) for a while and then finally upload it to the board. If connections have been done properly, the LED will blink.


  1. If the proper port has not been detected, go to Tools and then Port, and try the different ports – one must be the port at which the Arduino is connected.
  2. If compiling the sketch is taking a lot of time, it might be due to an antivirus installed on your computer – temporarily disable the antivirus, or in the advanced options (or similar) of your respective antivirus, add an exception for the entire Arduino installation folder (C:/Program Files(x86)/Arduino)

Have Something to Say? Write it Here!

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s