Introduction: Make an LED Blink With Arduino

The outcome of this tutorial is a blinking LED controlled by an Arduino UNO. For this tutorial, no special knowledge of electronics, nor programming is needed.

Things you need

  • Arduino UNO
  • USB-A to USB-B cable

Step 1: Physical Connection

Connect the Arduino to the Laptop/PC. The physical connection is established via a USB-A to USB-B cable as shown in the picture above. This is all you need on the Hardware side. The blinking LED is already build into the Arduino on PIN 13.

Step 2: Software Preparation

Prepare the Arduino IDE (programming software) as described in step 3 and 4 of this tutorial.

Step 3: Basic Understanding of an Arduino Sketch

Almost all Arduino sketches have three parts.

  • Variable declaration

In the first part, the variables are declared and the libraries are called. This part is not a must, for this project it is not needed but will be used in future projects so it’s good to know about it.


  • The setup

The setup is only executed once. Here the PINs are declared as input or output pins. If a PIN is declared as INPUT, then the microcontroller is waiting for a voltage. If the PIN is declared as OUTPUT, it can have a certain output voltage.

  • The Loop

The loop is the part that is repeated continuously. The first time the microcontroller is booted, this runs through the whole code and then repeats the loop as long as it has power.

Step 4: First Sketch

As said before, no variables must be declared for this project so we can jump right to the setup. Because the Arduino has a build in LED on PIN 13, there is no need to use a separate LED. Because we use PIN 13 for this project, this must be declared in setup as follows.

<p>void setup() {<br>pinMode(13,OUTPUT);   //in this row you declare PIN 13 as an output pin
}</p>

Now we have to tell the microcontroller to output voltage on the certain PIN, this is done with the following code:

digitalWrite(13, HIGH);

If a PIN is set to HIGH, this will have an output voltage of 5V. The voltage will stay the same as long as it is not changed by the code. If we want the LED to stay on for one secound, we can delay the next move. The delay function takes the argument in millisecounds. One secound represents 1000ms so the line of code looks like this:

delay(1000);

By changing the delay time, a faster or slower blinking is obtained. After the delay, PIN 13 is set back to LOW and another delay is set until the loop starts again from the beginning:

digitalWrite(13,LOW);<br>delay(1000);

The file can be downloaded below or you can write it alone.

The download version also has comments to explain each line of code.

Step 5: Be Proud With Your First Sketch

Now you have to upload the sketch to your Arbuino board. If you did everything right, you should see the blue marked LED blink at the speed you set.