Follow Us
Facebook Twitter Google Plus Linkedin Instagram YouTube

Arduino Lesson 1- LED Blinking

The exciting journey of learning any new electronics platform starts with blinking an LED. This is popularly called as Hello world of Electronics. So, let us start with this new exciting Arduino learning journey.


 

First of all you need to download and install Arduino IDE on your PC. This software is required for programming of Arduino board. You can download it from here.

Components Required:

  1. Arduino UNO
  2. 5mm LED (Any Color)
  3. 220Ω resistor
  4. Connecting wires

LED Basics:

LED stands for Light Emitting Diode. Diode is an electronics component which conducts current only in one direction and blocks in other direction. LED has two legs one is longer called Anode (+) and shorter called Cathode(-). So when positive voltage is applied to Anode and ground is applied to Cathode then LED starts conducting current and glows. And when connected in opposite direction, it stops conducting and not glow.

Interfacing:

Here we have connected longer leg of LED to the digital Pin 4. But you could choose any other digital pin of your choice. The shorter leg of LED is connected to ground.

 

Programming:

Before start coding let us understand the logic behind blinking LED. Blinking LED means turning LED on for few seconds and off for other few seconds. As we learnt in LED Basics, to turn LED on we need to apply positive voltage to long leg and short leg is already connected to ground. This could be done by making pin 4 high, and to turn LED off we need to make pin 4 low. That’s it…

Here comes the LED blinking program as per the above logic.


// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(4, OUTPUT);
}


// the loop function runs over and over again forever
void loop() {
digitalWrite(4, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000);                     // wait for a second
digitalWrite(4, LOW);  // turn the LED off by making the voltage LOW
delay(1000);                     // wait for a second
}

Now first check the code for any errors. This could be done by pressing verify button as shown below.

Now connect Arduino to PC with cable. Before uploading code to board we need to select the type of board and it’s port number. This could be done by clicking on Tools>>Board>>Arduino/Genuino UNO and to choose port click on Tools>>Port>>Select COM Port named Arduino/Genuino UNO.

Now you are ready to upload the code. Now just click on Upload Button and wait till upload is complete. After completing upload LED should start blinking. For more fun try changing the delay on code and observe the changes in blinking rate.

Leave a Reply

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

Bitnami