top of page
Post: Blog2 Post
Search

How to blink an LED using an Arduino





In this project, we will be blinking an LED light on and off using an Arduino. These are the materials that we will be using :


Materials :


  1. Arduino

  2. Breadboard (any size)

  3. LED Light (any color)

  4. Resistor - 220 Ohm

  5. Jumper Wires

  6. Battery/Cable Source


If you don't have any of these materials, you can buy the kit in our shop :



Software :





Circuit :


In this Circuit our goal is to make sure the LED light has enough voltage to keep the energy flowing. The LED light''s positive pin, which longer pin, is connected to a 220 ohm resistor. A resistor is used to limit the current through the LED and to prevent excess current that can burn out the LED. If the voltage source is equal to the voltage drop of the LED, no resistor is required. The resistor is then connected to pin 2, which where we will use to send power through. The negative pin, the shorter one, is connected to the ground pin (GND). The reason for connecting the negative cable to ground is to minimize the chances of a spark near the battery, where there may be potentially explosive gasses. Now we can move into the programming side .


Here's a sketch of how you circuit should look like :



Programming


The first step of programming set up your code. First we have to make a variable that we will set to the number pin we put in the Arduino, in our case 2. Them we used the "pinMode" command to help us declare that an LED is an output, which means the Arduino will be sending voltage through pin 2. The last part is a loop that constantly repeats it self when the code inside it is done. In the first line we have turned on the LED by using the command "HIGH". Then we put a wait time of 1000 milliseconds (1 second), for it to stay on for 1 second. After that we turned the LED off by using the command "LOW" for another 1 second. Since this a loop, this will keep repeating which means the LED will turn on and off.


Code :


int LEDlight = 2;                   //

void setup()
{
  pinMode(LEDlight, OUTPUT);
}

void loop()
{
  digitalWrite(LEDlight, HIGH);
  delay(1000); // Wait for 1000 millisecond(s)
  digitalWrite(LEDlight, LOW);
  delay(1000); // Wait for 1000 millisecond(s)
}


After finishing writing the code, download it using the the USB cable to download it to the Arduino. Before that you have to make sure the board type is the right one and it's setup to the right port. To do that go to the tools section choose the board type and port. In this case we are using an Arduino Uno. Finally connect the cable and see what happens. See the image below :





  • Make sure to like the post

  • Comment down below if it worked for you and what other projects you want me to keep doing!

You can find the forum for this project here :

bottom of page