blogs

Arduino Blink Project

2022-Jun-21

So, before getting started into advanced projects with Arduino let's dive into the simplest and basic project we could do using an Arduino. The LED Blink project is one of the simplest projects to carry out in understanding the basic working mechanism of Arduino.


So, let’s get started!


Components Required: So, let’s collect all the basic components required to build this project that includes:


  1. Arduino UNO with cable

  2. LED

  3. Resistors

  4. Male to Male Jumper Wires

  5. Power Supply

  6. Bread board


Step 1: Carry out the provided connections

 


As you can see in this image the positive terminal of the LED is connected with the 12th pin of the arduino through a resistor of 100 ohm. Here the resistor is used to reduce the current flow as an LED could work with even a very small voltage and current.



Well in case if you couldn't find which of the LED terminals is the positive one then look for its length. The one with the longer leg is the Positive terminal or anode while the other one is the cathode which is connected to the ground terminal of the arduino board.

 


If for some reason you still couldn’t identify the terminals then let me show you through this image. Here you can see that one of the terminals inside the LED has a larger plate connected to it while the other one has a small plate. The terminal connected with the larger plate is the cathode/ negative terminal while the one with the smaller plate is the anode/ positive terminal.



Upon connecting the LED, now let's get towards the coding section. The code for the blinking program could be the simplest, shortest and easiest to understand. The image shows the code for this project. 



Here, the region at void setup is used for defining all the pins whether they are for input or for output. In this case we are not taking any input for the Arduino and our task is to only light and blink an LED so we define any of the digital pins for output (in this case we are using the 12th pin). It is assigned using the code pinMode(12, OUTPUT);



Upon assigning the output pin we move forward to the looping section. Here the void loop in Arduino is an infinite loop. Our purpose is to blink the LED light which in general means that we need to turn the LED on and off continuously. In this loop section we firstly turn the LED on using the code digitalWrite(12, HIGH);. 


We have to turn this LED on for a second and then turn it off for another second and then continue this loop infinitely, hence inside the void loop. delay(1000); is the keyword used to hold the previous execution for a second. Here the 1000 inside the delay refers to 1000 microseconds which equals to 1 second.



void setup() 

{

pinMode(12, OUTPUT);

}


void loop() 

{

  digitalWrite(12, HIGH);     

  delay(1000);                        

digitalWrite(12, LOW);     

delay(1000);                   

}



Immediately following the delay we are to turn the LED off and hold it for a second using the keyword digitalWrite(12, LOW); followed by a delay.



Finally, upload this code to your Arduino board. Don't forget to select your port and your boards before you do so.


Turn off your room light and enjoy the LED blink that you just created. Now you’re ready to start more of your own interesting projects using Arduino. Happy Arduinoing!