Docsity

IOT Practical 3 write-up TE AIDS SPPU 2024 Pattern, Study Guides, Projects, Research of Internet and Information Access

Toggle sidebar
bg1
PRACTICAL EXPERIMENT NO. 3
Title: Control an LED through GPIO pins to understand the physical design of IoT devices and device
actuation.
Problem Statement: Implement a simple IoT application using an Arduino board to control an LED through
GPIO pins in order to understand the physical design of IoT devices and device actuation.
Aim: Write a program(simple IoT application) to control an LED through GPIO pins to understand the physical
design of IoT devices and device actuation.
Objectives:
• To study and understand GPIO pins.
• To understand the physical design of IoT devices and device actuation.
• To understand controlling an LED through GPIO pins.
Prerequisites:
• Knowledge of C, C++, Java Programming.
• Knowledge of Arduino IDE, LEDs.
Outcome: An application(program) which controls an LED through GPIO pins to show understand the
physical design of IoT devices and device actuation.
Software requirements: 64-bit Open Source Operating System (Windows/Ubuntu), ardOS/Arduino IDE
Hardware requirements: Arduino Uno and LED.
Theory:
Introduction to GPIO
General-Purpose Input/Output (GPIO) pins are digital pins on an integrated circuit (IC) that can be
configured as either input or output to interface with various devices.
• Input: If you need to read data, such as from a switch or sensor, the pin is configured as an input.
• Output: If you need to control devices like LEDs, motors, or displays, the pin is configured as an
output.
Arduino Uno GPIO Pin Diagram
The Arduino Uno board features multiple digital I/O pins that can be used to connect to input or output
devices. The following image shows the digital I/O pin layout of the Arduino Uno board.
pf3
pf4
pf5

Partial preview of the text

Download IOT Practical 3 write-up TE AIDS SPPU 2024 Pattern and more Study Guides, Projects, Research Internet and Information Access in PDF only on Docsity!

PRACTICAL EXPERIMENT NO. 3

Title : Control an LED through GPIO pins to understand the physical design of IoT devices and device actuation. Problem Statement: Implement a simple IoT application using an Arduino board to control an LED through GPIO pins in order to understand the physical design of IoT devices and device actuation. Aim: Write a program(simple IoT application) to control an LED through GPIO pins to understand the physical design of IoT devices and device actuation. Objectives:

  • To study and understand GPIO pins.
  • To understand the physical design of IoT devices and device actuation.
  • To understand controlling an LED through GPIO pins. Prerequisites:
  • Knowledge of C, C++, Java Programming.
  • Knowledge of Arduino IDE, LEDs. Outcome: An application(program) which controls an LED through GPIO pins to show understand the physical design of IoT devices and device actuation. Software requirements: 64 - bit Open Source Operating System (Windows/Ubuntu), ardOS/Arduino IDE Hardware requirements: Arduino Uno and LED. Theory: Introduction to GPIO General-Purpose Input/Output (GPIO) pins are digital pins on an integrated circuit (IC) that can be configured as either input or output to interface with various devices.
  • Input : If you need to read data, such as from a switch or sensor, the pin is configured as an input.
  • Output : If you need to control devices like LEDs, motors, or displays, the pin is configured as an output. Arduino Uno GPIO Pin Diagram The Arduino Uno board features multiple digital I/O pins that can be used to connect to input or output devices. The following image shows the digital I/O pin layout of the Arduino Uno board.

Digital Input and Output in Arduino (ATmega) Arduino’s analog pins can also function as digital input/output pins. Digital Output Arduino’s digital pins can be configured as outputs to drive devices like LEDs and LCDs. To configure a pin as an output, we use the pinMode() function, which sets the pin’s direction as either input or output. pinMode(pin, mode) - This function configures the specified GPIO pin as either input or output.

  • pin : The pin number you want to configure.
  • mode : Can be INPUT, OUTPUT, or INPUT_PULLUP. Example: pinMode(3, OUTPUT); // Set pin 3 as an output Arduino (ATmega) pins can source or sink a current of up to 40 mA, which is enough to drive devices like LEDs or an LCD display. However, this is insufficient for power-hungry devices like motors or relays. Note : When connecting devices to Arduino output pins, always use a current-limiting resistor. Drawing more than 40 mA from an Arduino pin could damage the pin or the IC. The output from these pins can be either HIGH (5V or 3.3V) or LOW (0V). To set the output value on these pins, we use the digitalWrite() function. digitalWrite(pin, value) - This function sets the output value of the specified pin to either HIGH (5V) or LOW (0V). Example: digitalWrite(3, HIGH); // Set pin 3 to HIGH (5V) Digital Input To read data from a sensor or another device, we configure a digital pin as an input. By default, Arduino pins are set as digital inputs, so explicit configuration isn’t necessary unless the pin has been previously set to an output. If you want to explicitly set a pin as an input, use the pinMode() function. digitalRead(pin) - This function reads the value of the specified GPIO pin, returning either HIGH or LOW depending on the input signal. Digital Input with Pull-up Resistor When a pin is configured as an input with nothing connected to it, it can enter a high-impedance or floating state , which may cause random changes in the pin’s state. To avoid this, you can add a pull-up or pull-down resistor to stabilize the input.
  • Pull-up resistor : Connects the pin to +5V, ensuring the input state is defined when no external device is connected.
  • Pull-down resistor : Connects the pin to GND, ensuring the input state is defined. The INPUT_PULLUP mode in the pinMode() function enables the internal pull-up resistor, which connects the pin to 5V. This is a common method to prevent floating input states. Example: pinMode(3, INPUT_PULLUP); // Set pin 3 as an input with an internal pull-up resistor This setup avoids the floating state and ensures reliable input readings.

Understanding Physical Design of IoT Devices by controlling LED The physical design of an IoT device requires creating a complete electrical circuit from a controller pin to a ground source. Resistors are mandatory in physical design to manage voltage levels and prevent hardware damage. Device actuation Device actuation is the physical process where these systems convert digital control signals into real-world mechanical, thermal, or optical actions. The method of taking a digital command from a processor and driving a physical change in the environment.  Signal Conversion: Translates low-voltage electrical pulses into higher power or physical motion using drivers or amplifiers.  Common Examples:

  • Motors and Servos for precise mechanical positioning.
  • Relays and Solenoids for switching high-current appliances or fluid valves.
  • Pumps and Heaters for changing fluid dynamics or ambient temperature.  Design Considerations: Requires isolation from sensitive sensor circuitry to prevent electrical noise and voltage spikes. Understanding Device Actuation (The Code) by controlling LED Actuation is the process of converting an electrical signal into physical action (in this case, light). The digitalWrite(pin, HIGH) command changes the physical state of the environment by allowing current to flow. Implementation Apparatus: Arduino Uno board, USB Cable, 1 x 220 Ω Resistor, 1 x LED. Interface/Connections: Procedure: Step 1: Connect the Arduino board to CPU using the FRC cable provided with the board. Step 2: Connect the Power supply adaptor and power on the circuit. Step 3: Open Arduino IDE and create a new sketch (program) using the connections.

Step 4: In the Arduino IDE go to tools →Port and select the appropriate COM port.

Step 5: In the Arduino IDE click on the upload button to compile and download the code into the Arduino UNO. When successfully downloaded, the code will start running. Step 6: Observe and control LED by delay(). Observations: Pins that can be programmed to either read data (input) or command hardware (output).. Observation Table: Conclusion: An application was developed using Arduino for controlling an LED through GPIO pins showing connectivity of the physical design of IoT devices and device actuation successfully. Peripheral Arduino Pin LED Cathode (-ve) GND LED Anode (+ve) Resistor + D 13 Time (in milliseconds) LED State 999 OFF 1000 ON 2000 OFF

Viva Questions:

  1. What is GPIO?
  2. What are the GPIO pins in Arduino?
  3. How to control LED?
  4. How Implementing a simple IoT application using an Arduino board to control an LED through GPIO pins helps to understand the physical design of IoT devices and device actuation?