Getting Started with Arduino – LED Blinking

Getting Started with Arduino – LED Blinking

Arduino Uno R3
Arduino Uno R3

Arduino Uno is the best development board for beginners in the field of embedded systems. We can program Arduino board with less technical knowledge and programming skills. This tutorial is intended to beginners in the field of Arduino. Hope you already have an Arduino board. Then you have to download Arduino Software and Driver. You can download it from Arduino Website.

Installing Arduino Driver

Now connect the Arduino to your computer using a USB cable. As usual Windows may start driver installing procedure but it will fail after some time. We need to install driver manually which comes along with Arduino Software.

Right Click on My Computer
Arduino Driver Installing Step 1
Arduino Driver Installing Step 1
Select Manage >> Device Manager
Arduino Driver Installing Step 2
Arduino Driver Installing Step 2

You can find Arduino under the Ports (COM & LPT). If it is not listed there, look under Other Devices >> Unknown Device.

Double Click on the Unknown Device, you can see details.


Arduino Driver Installing Step 3
Arduino Driver Installing Step 3
Select Update Driver

Arduino Driver Installing Step 4
Arduino Driver Installing Step 4
Select “Browse My Computer for driver software”

Arduino Driver Installing Step 5
Arduino Driver Installing Step 5

Extract the downloaded zip file. Select the folder “drivers” in the extracted folder.

 Click Next

Arduino Driver Installing Step 6
Arduino Driver Installing Step 6

Hope you successfully installed driver.

Now we can start Arduino programming. All of us start learn a new programming from Hello World. In microcontroller fields the Hello World example is usually blinking an led. In Arduino Uno, there are 4 on-board LEDs. One for indicating power, two (RX and TX) for indicating serial communication between Computer and Arduino. The remaining one is connected to PIN : 13. Thus when the digital pin 13 is HIGH, LED turns ON and when it is LOW, LED will be OFF.

Firstly we can start by blinking this on board LED. Arduino IDE comes with a lot of examples, which makes our task simpler.

  • Open the Arduino IDE
Arduino IDE
Arduino IDE
  • Open File >> Examples >> 01. Basics >> Blink
Opening LED Blinking Example
Opening LED Blinking Example
  • It will open the sketch (code) for blinking on board LED connected to PIN : 13
Sketch of LED blinking
Sketch of LED blinking

On-Board LED Blinking – Arduino Sketch

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

This example code is in the public domain.
*/

// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;

// the setup routine runs once when you press reset:
void setup() {
    // initialize the digital pin as an output.
    pinMode(led, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
    digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
    delay(1000); // wait for a second
    digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
    delay(1000); // wait for a second
}
  • Now make sure that your board is selected correctly, Tools >> Board >> Arduino Uno
Selecting Arduino board
Selecting Arduino board
  • Select the COM PORT to which the Arduino is connected to your computer using the menu Tools >> Serial Port.
  • To find COM PORT, Right Click on My Computer >> Manage >> Device Manager >> Ports (COM & LPT)

Getting COM Port Number
Getting COM Port Number

Arduino - Selecting COM Port
Arduino – Selecting COM Port
  • Now you can compile the sketch by clicking on the Verify Button

Varifying button

 Compiling Process will be started when you click Verify Button

Compiling the Sketch
Compiling the Sketch
If the compilation process is completed successfully, “Done Compiling will be displayed on the bottom left of your IDE.

After Compiling
After Compiling

 

Now we can upload the sketch to Arduino Board by simply clicking on the Upload Button.

Uploading Button

You can see that the RX and TX LEDs on your board is blinking indicating data transfer. A message “Done Uploading” will be displayed at the bottom of the IDE on completion. Automatic reset of the Arduino board will happen after uploading the program.

After Uploading
After Uploading

After uploading you can see blinking on-board LED.

 Blinking An External LED

Now we can try blinking an external LED connected to a digital pin (say 8) of Arduino.

Circuit Diagram

Arduino Uno connected to an LED
Arduino Uno connected to an LED
Arduino Uno connected to LED - Schematic
Arduino Uno connected to LED – Schematic

LED is connected to 8th digital pin of Arduino. A 680Ω resistor is connected in series to limit the current through the LED.

Sketch

Just change the pin number in the above program to 8.

int led = 8;
void setup() {
    pinMode(led, OUTPUT);
}

void loop() {
    digitalWrite(led, HIGH);
    delay(1000);
    digitalWrite(led, LOW);
    delay(1000);
}

Now Just Verify and Upload the program, you can see the blinking LED.

Share this post


>