Home IoT Project Blinking of led using Aurdino Uno

Blinking of led using Aurdino Uno

by anupmaurya
11 minutes read

Here we are going to blink an LED for every 500ms using Aurdino Uno. In arduino uno, a LED has already inbuilt at the pin13, but we are not going to use it.

Components Required

Hardware: Arduino uno board, connecting pins, 220Ω resistor, LED, breadboard.

Software: Arduino Nightly

Circuit

Here we are going to connect an indicating LED to PIN7 through a current limiting resistor.

The controller in arduino is already programmed to work on external crystal. So we need not to worry about fuse bits or anything. The arduino works on 16Mhz crystal clock, which is already embedded in the board.

Blinking of led using Aurdino Uno
Blinking of light using Aurdino Uno

Code for Blinking of led using Aurdino Uno

Code
// The setup function runs when you press reset or power the board

void setup()

{

 // initialize digital pin 0 as an output.

pinMode(7, OUTPUT);

 }

// the loop function runs over and over again forever

void loop()

{

digitalWrite(7, HIGH);   // turn the LED on (HIGH is the voltage level)

delay(500);              // wait for a second

digitalWrite(7, LOW);    // turn the LED off by making the voltage LOW

delay(500);              // wait for a second

} 

Explanation of Blinking of led using Aurdino Uno Code

Above code controls an LED (Light Emitting Diode) connected to the board. Let’s break it down step by step:

1. setup() function:

  • This function runs only once when you start the Arduino or press the reset button.
  • Inside setup(), the line pinMode(7, OUTPUT); configures pin number 7 on the Arduino board to be an output pin. This means the program can control the voltage level on that pin.

2. loop() function:

  • This function runs repeatedly, creating a loop that keeps the program running.
  • Inside loop(), two lines control the LED:
    • digitalWrite(7, HIGH); sets the voltage on pin 7 to HIGH. In Arduino, HIGH typically corresponds to 5 volts. This turns the LED on.
    • delay(500); pauses the program for 500 milliseconds (half a second).
    • digitalWrite(7, LOW); sets the voltage on pin 7 to LOW (usually 0 volts). This turns the LED off.
    • Another delay(500); pauses again for 500 milliseconds.

You may also like

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.