Jump to content

MDM331AID/Experiment 3

From cognifront

Experiment 3: Arduino-Based LED Control Using GPIO Pins

Aim

To implement a simple IoT-oriented application using an Arduino UNO board to control an LED through GPIO pins and understand the physical design of IoT devices and the concept of device actuation.

Objectives

  • To understand the physical components of an IoT device.
  • To configure Arduino GPIO pins as digital outputs.
  • To control an LED using digital signals.
  • To understand the role of actuators in IoT applications.
  • To observe the relationship between software commands and physical device actions.

Components Required

Sr. No. Component Quantity
1 Arduino UNO Development Board (COG-U1) 1
2 LED bar available on the Arduino kit 1
3 USB data cable 1
4 Patch cords As required
5 Computer with Arduino IDE 1


Theory

Physical Design of an IoT Device

An IoT device consists of physical hardware and software that work together to sense, process, communicate, and perform actions. A typical IoT device includes the following components:

  • Processing unit: A microcontroller or processor that executes the program and controls device operations.
  • Input interface: GPIO pins and sensor interfaces used to receive data from external components.
  • Output interface: GPIO pins used to control actuators such as LEDs, buzzers, relays, and motors.
  • Communication interface: Wi-Fi, Bluetooth, Ethernet, or other communication technologies used to exchange data.
  • Power supply: Provides the electrical energy required for device operation.

In this experiment, the Arduino UNO acts as the processing unit, and the LED acts as a simple output actuator.

GPIO Pins

GPIO stands for General Purpose Input/Output. These pins allow a microcontroller to interact with external electronic components.

Arduino UNO digital pins can be configured as:

  • INPUT: To read digital signals.
  • OUTPUT: To generate digital signals.
  • INPUT_PULLUP: To read digital signals using an internal pull-up resistor.

For LED control, the GPIO pin is configured as an output.

Device Actuation

Actuation is the process of converting a control signal into a physical action. In this experiment, the Arduino generates a digital HIGH or LOW signal on a GPIO pin to switch the LED on or off.

  • HIGH: The output pin is set to a logic HIGH voltage, approximately 5 V on an Arduino UNO.
  • LOW: The output pin is set to a logic LOW voltage, approximately 0 V.

This demonstrates a basic form of device actuation. In a complete IoT system, commands could be received over a network and used to control the same GPIO output.

Pin Connections

Arduino UNO Pin LED Bar Connection Description
D8 LED bar input Digital output for LED control
GND LED bar GND Common ground

Note: The connection above assumes that the LED bar has a compatible input connection for direct GPIO control. Verify the LED bar's actual pin labels and current-limiting arrangement before connecting it. If the kit's LED bar uses a different interface, follow its board-specific connection details.

Connection Diagram

        Arduino UNO
      +-------------+
      |             |
      |         D8  |---------------- LED Bar Input
      |             |
      |        GND  |---------------- LED Bar GND
      |             |
      +-------------+

Arduino Program

const int ledPin = 8;

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

void loop() {
  // Turn LED ON
  digitalWrite(ledPin, HIGH);
  delay(1000);

  // Turn LED OFF
  digitalWrite(ledPin, LOW);
  delay(1000);
}

Code Explanation

Statement Description
const int ledPin = 8; Defines digital pin 8 as the LED control pin.
pinMode(ledPin, OUTPUT); Configures the selected GPIO pin as an output.
digitalWrite(ledPin, HIGH); Sets the GPIO output to HIGH to turn the LED on, assuming active-HIGH wiring.
delay(1000); Pauses program execution for 1000 milliseconds.
digitalWrite(ledPin, LOW); Sets the GPIO output to LOW to turn the LED off, assuming active-HIGH wiring.

Procedure

  1. Connect the Arduino UNO board to the computer using the USB data cable.
  2. Connect the LED bar input to digital pin D8 and its ground to Arduino GND, after verifying the LED bar's pinout and compatibility.
  3. Open the Arduino IDE.
  4. Select the appropriate Arduino UNO board and COM port.
  5. Enter the given Arduino program.
  6. Compile and upload the program to the Arduino UNO.
  7. Observe the LED switching on and off at one-second intervals.
  8. Modify the delay values and observe how the blinking speed changes.

Observations

Sr. No. GPIO Output Expected LED State
1 HIGH ON
2 LOW OFF
3 HIGH ON
4 LOW OFF

The expected output is a repeating sequence of one second ON followed by one second OFF. Actual behavior depends on the LED bar's electrical interface and polarity.

Result

The Arduino UNO was programmed to control an LED through a GPIO pin. The experiment demonstrates GPIO output configuration and basic device actuation, illustrating how software commands can produce physical actions in an IoT device.

Viva Questions

  1. What is the full form of GPIO?
  2. What is the function of a microcontroller in an IoT device?
  3. What is the difference between digital input and digital output?
  4. What is device actuation?
  5. What is the purpose of the pinMode() function?
  6. What is the function of digitalWrite()?
  7. What is the difference between HIGH and LOW logic levels?
  8. Why is a current-limiting resistor required for a conventional LED?
  9. What is the role of a communication interface in an IoT device?
  10. How could this experiment be extended to control an LED remotely over Wi-Fi?