To blink an LED using Arduino UNO

Aim of the Experiment

To blink an LED using Arduino UNO.

Objective

The objective of this experiment is to learn the basics of using an Arduino UNO microcontroller board and successfully blink an LED connected to an Arduino UNO by writing and uploading a simple code.

Components Required

The required components are:

  1. Arduino UNO board
  2. LED (Light Emitting Diode)
  3. 220-ohm resistor
  4. Breadboard
  5. Jumper wires

Circuit Diagram

Blink led using Arduino

Circuit Connection

  1. Connect the longer leg (anode) of the LED to digital pin 13 of the Arduino UNO.
  2. Connect the shorter leg (cathode) of the LED to one end of the 220-ohm resistor.
  3. Connect the other end of the resistor to the GND (ground) pin on the Arduino UNO.
  4. Ensure that the components are connected properly and securely to the breadboard.

Procedure

  1. Set up the circuit as described in the “Circuit Connection” section.
  2. Connect the Arduino UNO to your computer using a USB cable.
  3. Open the Arduino IDE software on your computer.
  4. Write the code for blinking the LED (explained in the next section).
  5. Verify and upload the code to the Arduino UNO.
  6. Observe the LED blinking at a specific interval.

Writing the Code

// Define the pin number for the LED

const int ledPin = 13;

void setup() {

  // Set the LED pin as an output

  pinMode(ledPin, OUTPUT);

}

void loop() {

  // Turn on the LED

  digitalWrite(ledPin, HIGH);

  // Delay for 1 second

  delay(1000);

  // Turn off the LED

  digitalWrite(ledPin, LOW);

  // Delay for 1 second

  delay(1000);

}

Code Explanation

  1. In the code, we start by defining a constant integer `ledPin` and assign it the value 13. This pin corresponds to the digital pin where the LED is connected.
  2. The `setup()` function is called once when the Arduino board powers up. In this function, we set the `ledPin` as an output using the `pinMode()` function.
  3. The `loop()` function is where the main logic of the code resides. It is executed repeatedly after the `setup()` function.
  4. Inside the `loop()`, we turn on the LED by setting the `ledPin` to `HIGH` using `digitalWrite()`.
  5. We then introduce a delay of 1 second (1000 milliseconds) using the `delay()` function.
  6. After the delay, we turn off the LED by setting the `ledPin` to `LOW` using `digitalWrite()`.
  7. Another 1-second delay is introduced before the loop starts again, resulting in the LED blinking at a 1-second interval.

Conclusion

By following the given procedure and uploading the provided code, the LED connected to pin 13 of the Arduino UNO successfully blinks at a 1-second interval. This experiment helps in understanding the basics of controlling hardware components using an Arduino microcontroller.

Precaution

  1. Ensure that the circuit connections are accurate and secure to avoid any short circuits.
  2. Double-check the polarity of the LED (longer leg as an anode, shorter leg as a cathode) and connect it accordingly.
  3. Be cautious while handling the Arduino UNO and avoid any contact with water or conductive materials that may cause damage to the board or components.

Author

Akash Sharma

Share This Post

Leave a Comment