LED blinking project

Creating a project titled “LED Blinking Using Arduino” is an excellent way to learn about microcontrollers and basic programming! Here’s a step-by-step guide:

Objective:

The goal is to make an LED blink on and off at regular intervals using an Arduino board.

Components Required:

  • Arduino Uno or any Arduino board
  • LED (Light Emitting Diode)
  • Resistor (220 ohms)
  • Breadboard
  • Jumper wires
  • USB cable (to connect Arduino to the computer

Circuit Design:

  1. Connect the positive leg (longer leg) of the LED to a digital pin on the Arduino (e.g., pin 13).
  2. Connect the negative leg (shorter leg) of the LED to one terminal of the resistor.
  3. Connect the other terminal of the resistor to the GND (ground) pin of the Arduino.
  4. Ensure all connections are firm on the breadboard.

What is Arduino?

Arduino is an open-source, board that has a Microchip ATmega328P microcontroller on it. This microcontroller has a set of Digital & Analog input and output pins. The operating voltage of the board is 5V. It has 14 digital I/O pins & 6 Analog input pins. The clock frequency of the microcontroller is 16 MHz.

What is LED?

LEDs (Light Emitting Diodes) are becoming increasingly popular among a wide range of people. When a voltage is given to a PN Junction Diode, electrons, and holes recombine in the PN Junction and release energy in the form of light (Photons). An LED’s electrical sign is comparable to that of a PN Junction Diode. When free electrons in the conduction band recombine with holes in the valence band in forward bias, energy is released in the form of light.

What is LED

Structure of an LED

Structure of LED

Structure of LED

The flow of charge carriers (electrons and holes) across the P-N junction drives the activity of an LED. When a forward voltage (anode positive in comparison to the cathode) is applied, electrons and holes recombine at the junction, releasing energy in the form of photons (light). The semiconductor chip is linked to external terminals known as the anode (+) and the cathode (-). The anode is linked to the P-region, and the cathode to the N-region.

Blinking an LED

Blinking an LED is an introductory Arduino project in which we control an LED using Arduino. LED blinking refers to the process of continuously turning an LED (Light Emitting Diode) and off in a repetitive pattern. It is a simple and common demonstration in electronics and microcontroller-based projects.

Working Procedure

setup() and loop() are two fundamental Arduino functions for controlling the behavior of your board. The Arduino framework automatically calls these functions, which form the foundation of any Arduino program.

The setup() function is only called once when the Arduino board boots up or is reset. Its goal is to set pin modes, initialize variables, and execute any other necessary setup tasks before the main loop begins. This function can be used to configure settings that should only be changed once over the board’s lifespan.

The loop() function is the heart of an Arduino program. After the setup() function is executed, the loop() function starts running repeatedly until the Arduino is powered off or reset. It contains the main code that performs the desired tasks, controls the board, user input. Whatever is included in the loop() function will be executed in a continuous loop, allowing the Arduino to perform its intended functions continuously.

In the code, we have declared two integers, LEDpin and delayT. LEDpin represents the pin number of the Arduino where LEDs need to be connected, and delayT is an integer variable for the delay() function. The delay() function accepts values in milliseconds.

Arduino Code:

Upload this sample code to the Arduino using the Arduino IDE:

cpp

void setup() {
  pinMode(13, OUTPUT); // Set pin 13 as an output pin
}

void loop() {
  digitalWrite(13, HIGH); // Turn LED on
  delay(1000);            // Wait for 1 second
  digitalWrite(13, LOW);  // Turn LED off
  delay(1000);            // Wait for 1 second
}

How It Works:

  • The pinMode() function sets pin 13 as an output pin.
  • You can use any other pin 0 to 13 if you want to set as output pin.
  • The digitalWrite() function sends a HIGH or LOW signal to pin 13, turning the LED on or off.
  • The delay() function pauses the program for a specified time in milliseconds (1000 ms = 1 second).

Testing:

  1. Connect the Arduino to your computer using the USB cable.
  2. Open the Arduino IDE, paste the code into the editor, and upload it to the board.
  3. Observe the LED blinking on and off at 1-second intervals.

Extensions:

  • Change the delay() values to modify the blinking speed.
  • Use multiple LEDs and experiment with patterns.
  • Integrate a button to control the blinking.