0% found this document useful (0 votes)
3 views

saravana

The document is a laboratory record for the Internet of Things course at P.S.R. Engineering College, detailing various experiments conducted using Arduino Uno. It includes instructions for installing the Arduino IDE, interfacing components like LEDs and push buttons, and constructing circuits for applications such as traffic monitoring and distance measurement with ultrasonic sensors. Each experiment outlines the aim, required hardware, procedures, code, and results.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

saravana

The document is a laboratory record for the Internet of Things course at P.S.R. Engineering College, detailing various experiments conducted using Arduino Uno. It includes instructions for installing the Arduino IDE, interfacing components like LEDs and push buttons, and constructing circuits for applications such as traffic monitoring and distance measurement with ultrasonic sensors. Each experiment outlines the aim, required hardware, procedures, code, and results.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 59

P.S.

R ENGINEERING COLLEGE
(An Autonomous Institution, Affiliated to Anna University, Chennai)
Approved by AICTE, New Delhi & Accredited by National Board of Accreditation (NBA)
Accredited by NAAC with “A+” Grade, Recognized under12 (B) of the UGC Act, 1956.
An ISO 9001:2015 Certified Institution
Sevalpatti(P.O),Sivakasi - 626140.Tamilnadu.

Department of Computer Science and Engineering

LABORATORY RECORD

191CS63 – INTERNET OF THINGS

VI – SEMESTER

MAY 2024
P.S.R. ENGINEERING COLLEGE
(An Autonomous Institution, Affiliated to Anna University, Chennai)
Approved by AICTE, New Delhi & Accredited by National Board of Accreditation (NBA)
Accredited by NAAC with “A+” Grade, Recognized under 12(B) of the UGC Act, 1956.
An ISO 9001:2015 Certified Institution
Sevalpatti (P.O), Sivakasi - 626140. Tamilnadu.
Department of Computer Science and Engineering

BONAFIDE CERTIFICATE

Certified that this is a Bonafide Record of work done

by

Roll No in the

Laboratory of this College during the academic year 2023-2024.

…………………………… …………………………………

Staff-in-Charge Head of the Department

Register No:

Submitted for the Practical Examination held on……………………………………………………

….……………………… …………………………………

Internal Examiner External Examiner


CONTENTS
Page
Ex. No. Date Name of the Experiment No. Marks Sign.
Arduino IDE
(Integrated Development Environment)
Introduction: The Arduino Software (IDE) is easy-to-use and is based on the
Processing programming environment. The Arduino Integrated Development
Environment (IDE) is a cross-platform application (for Windows, macOS,
Linux) that is written in functions from C and C++. The open-source Arduino
Software (IDE) makes it easy to write code and upload it to the board. This
software can be used with any Arduino board.

The Arduino Software (IDE) – contains:

 A text editor for writing code


 A message area
 A text consoles
 A toolbar with buttons for common functions and a series of
menus. It connects to the Arduino hardware to upload programs
and communicate with them.

1
Installation of Arduino Software (IDE)

Step1: Downloading

 To install the Arduino software, download this page: http://arduino.cc/en/Main/Software


and proceed with the installation by allowing the driver installation process.

Step 2: Directory Installation

 Choose the installation directory.

2
Step 3: Extraction of Files

 The process will extract and install all the required files to execute properly
the Arduino Software (IDE)

3
Step 4: Connecting the board

 The USB connection with the PC is necessary to program the board and not just to
power it up. The Uno and Mega automatically draw power from either the USB or an
external power supply. Connect the board to the computer using the USB cable. The
green power LED (labelled PWR) should go on.

Step 5: Working on the new project

 Open the Arduino IDE software on your computer. Coding in the Arduino
language will control your circuit.
 Open a new sketch File by clicking on New.

4
Step 6: Working on an existing project

 To open an existing project example, select File → Example → Basics → Blink.

5
Step 7: Select your Arduino board.

 To avoid any error while uploading your program to the board, you must select the
correct Arduino board name, which matches with the board connected to your computer.
 Go to Tools → Board and select your board.

Step 8: Select your serial port

 Select the serial device of the Arduino board.


 Go to Tools → Serial Port menu. This is likely to be COM3 or higher (COM1 and
COM2 are usually reserved for hardware serial ports).
 To find out, you can disconnect your Arduino board and re-open the menu, the
entry that disappears should be of the Arduino board. Reconnect the board and select
that serial port.

6
Step 9: Upload the program to your board.

 Click the "Upload" button in the environment.


 Wait a few seconds; you will see the RX and TX LEDs on the board, flashing.
 If the upload is successful, the message "Done uploading" will appear in the status bar.

A Verify

B Upload

C New

D Open

E Save

F Serial Motor

7
8
Arduino Uno
Introduction: The Arduino Uno is an open-source microcontroller board based on the
Microchip ATmega328P microcontroller and developed by Arduino.cc. The board is
equipped with sets of digital and analog input/output (I/O) pins that may be interfaced to
various expansion boards (shields) and other circuits. The board has 14 digital I/O pins (six
capable of PWM output), 6 analog I/O pins, and is programmable with the Arduino IDE
(Integrated Development Environment), via a type B USB cable. It can be powered by the
USB cable or by an external 9-volt battery, though it accepts voltages between 7 and 20 volts.
The word "uno" means "one" in Italian and was chosen to mark the initial release of Arduino
Software.

9
Power USB
1 Arduino board can be powered by using the USB cable from your computer.All
you need to do is connect the USB cable to the USB connection (1).

Power (Barrel Jack)


2 Arduino boards can be powered directly from the AC mains power supply by
connecting it to the Barrel Jack (2).

Voltage Regulator
The function of the voltage regulator is to control the voltage given to the Arduino
3
board and stabilize the DC voltages used by the processor and otherelements.

Crystal Oscillator
The crystal oscillator helps Arduino in dealing with time issues. How does Arduino
4 calculate time? The answer is, by using the crystal oscillator. The number printed on
top of the Arduino crystal is 16.000H9H. It tells us that thefrequency is 16,000,000
Hertz or 16 MHz.

Arduino Reset
You can reset your Arduino board, i.e., start your program from the beginning.You
5,17 can reset the UNO board in two ways. First, by using the reset button (17)on the
board. Second, you can connect an external reset button to the Arduino pin labelled
RESET (5).

Pins (3.3, 5, GND, Vin)


 3.3V (6) − Supply 3.3 output volt
 5V (7) − Supply 5 output volt
 Most of the components used with Arduino board works fine with
6,7,8,9 3.3volt and 5 volt.
 GND (8)(Ground) − There are several GND pins on the Arduino, anyof
which can be used to ground your circuit.
 Vin (9) − This pin also can be used to power the Arduino board
froman external power source, like AC mains power supply.

Analog pins
The Arduino UNO board has six analog input pins A0 through A5. These pinscan
10 read the signal from an analog sensor like the humidity sensor or temperature
sensor and convert it into a digital value that can be read by the microprocessor.

Main microcontroller
Each Arduino board has its own microcontroller (11). You can assume it as the brain
of your board. The main IC (integrated circuit) on the Arduino is slightly different
from board to board. The microcontrollers are usually of the ATMEL Company. You
11 must know what IC your board has before loading upa new program from the
Arduino IDE. This information is available on the topof the IC. For more details
about the IC construction and functions, you can refer to the data sheet.

10
ICSP pin
Mostly, ICSP (12) is an AVR, a tiny programming header for the Arduino consisting of
MOSI, MISO, SCK, RESET, VCC, and GND. It is often referredto as an SPI (Serial
12 Peripheral Interface), which could be considered as an "expansion" of the output.
Actually, you are slaving the output device to the master of the SPI bus.

Power LED indicator


This LED should light up when you plug your Arduino into a power source toindicate
13
that your board is powered up correctly. If this light does not turn on,then there is
something wrong with the connection.

TX and RX LEDs
On your board, you will find two labels: TX (transmit) and RX (receive). Theyappear
in two places on the Arduino UNO board. First, at the digital pins 0 and 1, to
14 indicate the pins responsible for serial communication. Second, the TX and RX led
(13). The TX led flashes with different speed while sending the serial data. The speed
of flashing depends on the baud rate used by the board. RX flashes during the
receiving process.

Digital I/O
The Arduino UNO board has 14 digital I/O pins (15) (of which 6 provide PWM (Pulse
Width Modulation) output. These pins can be configured to workas input digital pins
15 to read logic values (0 or 1) or as digital output pins to drive different modules like
LEDs, relays, etc. The pins labeled “~” can be used to generate PWM.

AREF
AREF stands for Analog Reference. It is sometimes, used to set an external
16
reference voltage (between 0 and 5 Volts) as the upper limit for the analog input
pins.

11
Ex.No:1
INTERFACING THE LED WITH ARDUINO UNO

AIM:

To construct the simple circuit for blinking the LED by using Arduino uno.

Hardware Require:

Components Quantity
1kohm Resistor 1
Red LED 1
Arduino Uno R3 1

Procedure:
 Built the circuit as per the circuit diagram.
 Components like resistor read to their terminal bend into 90degree angle in order
to fit the bread board socket.
 Open the Arduino UNO IDE software on your system.
 Code in the Arduino UNO language will central your circuit.
 Open the new sketch file by clicking new window.
 After finish the all circuit connections the write the code.

12
Code:
void setup()

pinMode(LED_BUILTIN, OUTPUT);

void loop()

digitalWrite(LED_BUILTIN, HIGH);

delay(1000); // Wait for 1000 millisecond(s)

digitalWrite(LED_BUILTIN, LOW);

delay(1000); // Wait for 1000 millisecond(s)

Circuit Diagram:

13
Result:

Thus the simple circuit for led blinking using Arduino was execute successfully
and the output was verified.

14
EX.NO:2
INTERFACING THE RGB LED WITH ARDUINO UNO

AIM:
To connect the simple circuit for blinking the RGB by using Arduino UNO.

Hardware Required:

Components Quantity
LED RGB 1
Arduino UNO 1
1 K ohm Resistor 3

Procedure:

 Insert RGB LED into breadboard with common cathode/anode to GND and
resistors to digital pins.
 Connect longer lead of RGB LED (anode) to current-limiting resistor, then
to Arduino's 5V pin.
 Open Arduino IDE, write code defining pins as outputs, then loop to turn
on/off RGB LED with delays.
 Connect Arduino Uno to computer via USB, select board and port in
Arduino IDE.
 Click "Upload" to compile and upload code to Arduino.
 RGB LED should blink with one second intervals for each color.
 Adjust code and connections as needed for specific setup.

15
Code:
void setup()
{

pinMode(13,OUTPUT);
pinMode(12,OUTPUT);
pinMode(11,OUTPUT);
}
void loop()
{
digitalWrite(13,HIGH); delay(1000);
digitalWrite(13,LOW);
delay(1000);
digitalWrite(12,HIGH);
delay(1000);
digitalWrite(12,LOW);
delay(1000);
digitalWrite(11,HIGH);
delay(1000);
digitalWrite(11,LOW);
delay(1000);
}

16
Circuit Diagram:

17
Result:
Thus the simple circuit for blinking RGB using Arduino was executed
successfully and the output was verified.

18
Ex. No:3
CONTROLLING THE LIGHT EMITTING DIODE (LED) WITH A
PUSH BUTTON

Aim:

To controlling the Light Emitting Diode(LED)with a Push Button.

Hardware Required:

Components Quantity
Arduino Uno R3 1
220 Ω Resistor 1
Red LED 1
1 kΩ Resistor 1
Pushbutton 1

Procedure:
 Insert the push button into your bread board and connect it to the digital pin 7
(07) which acts as input.
 Insert the LED into the bread board.
 Attach the positive leg (the longer leg) to digital pin 11 of the Arduino UNO.
 and the negative leg via the 220 ohm resistor to GND.

 The pin D11 is taken as output.


 The 10k ohm resistor to GND used as pull-up resistor and 220 ohm resistors its
used to limit the current through the LED.
 Upload the code as given below.
 Press the push button to control the ON state of LED.

19
Code:
const int buttonPin = 2;

const int ledPin = 11;

int buttonState = 0;

void setup()

pinMode(buttonPin, INPUT);

pinMode(ledPin, OUTPUT);

void loop()

buttonState = digitalRead(2); if

(buttonState == HIGH)

digitalWrite(ledPin, HIGH);

else {

digitalWrite(ledPin, LOW);

delay(10);

20
Circuit Diagram:

Result:

Thus the controlling of the Light Emitting Diode (LED) with a push button was
executed successfully and the output was verified.
21
Ex. No:4
TRAFFIC MONITORING SYSTEM

Aim:
To construct the simple circuit for traffic light the led by using Arduino Uno R3.

Hardware Required:

Components Quantity
Arduino Uno R3 1
Green led 1
Yellow led 1
Red led 1
220 ohm resistor 3

Procedure:
 Connect LED on the bread board as red, yellow, green respectively.

 Connect the negative terminal of the led and connect the 220 ohm resistor in series.

 Connect these negative terminal to the ground.

 Connect the positive terminal of the LED to the pins 2 to 10, respectively.

 Power the bread board by using 5v and GND on the Arduino.

22
Code:
void setup()
{
pinMode(0, OUTPUT);
pinMode(1, OUTPUT);
pinMode(2, OUTPUT);
}
void loop()
{
for (int i = 0 ; i < 10 ; i += 1)
{
digitalWrite(2, HIGH);
delay(100);
digitalWrite(2, LOW);
delay(100);
}
digitalWrite(2, HIGH);
delay(15000);
digitalWrite(2, LOW);
digitalWrite(1, HIGH);
delay(5000);
digitalWrite(1, LOW);
digitalWrite(0, HIGH);
delay(15000);
digitalWrite(0, LOW);
}

23
Circuit Diagram:

Result:
Thus the simple circuit for traffic light the LED by using Arduino Uno R3

24
successfully executed and the output was verified.

25
Ex. No:5
READING VALUES FROM ULTRASONIC SENSOR

Aim:

To construct the simple circuit for distance finding with ultrasonic sensors and
Arduino Uno

Hardware Required:

Components Quantity
Arduino Uno R3 1
Ultrasonic distance 1
sensor(4-pin)
1k ohms resistor 3
Red light 1
Yellow light 1
Green light 1

Procedure:
 open the Arduino IDE.

 select the type of board from tools board – Arduino Uno.

 select the port from tools – port – com.

 select the color lights like yellow, green, red and connect the light with Arduino
board
 upload the sketch to the connection diagram.
 verify the output.

26
Code:
int trig = 9; int

echo = 8; int

red = 10;

int yellow = 11; int

green = 12; long

duration = 0; int

cm = 0;

int in = 0;

void setup()

pinMode(trig, OUTPUT);

pinMode(echo, INPUT);

pinMode(red, OUTPUT);

pinMode(yellow, OUTPUT);

pinMode(green, OUTPUT);

Serial.begin(9600);

Serial.println("Serial Started...");

void loop()

digitalWrite(trig,LOW);

digitalWrite(trig,HIGH);

digitalWrite(trig,LOW);

27
int duration = pulseIn (echo, HIGH);

cm = duration*0.034/2;

in = duration*0.0133/2;

Serial.println(in);

if (in > 100){ digitalWrite(green, LOW);

digitalWrite(yellow, LOW);

digitalWrite(red, LOW);

delay(1000);

digitalWrite(green, HIGH);

digitalWrite(yellow, HIGH);

digitalWrite(red, HIGH);

delay(1000);

else if (in <= 100 && in >= 76)

//yellow

digitalWrite(green, LOW);

digitalWrite(yellow, LOW);

digitalWrite(red, LOW);

delay(600);

digitalWrite(green, HIGH);

digitalWrite(yellow, LOW);

digitalWrite(red, LOW);

28
delay(600);

else if (in <= 75 && in >= 51)

digitalWrite(green, LOW);

digitalWrite(yellow, LOW);

digitalWrite(red, LOW);

delay(600);

digitalWrite(green, LOW);

digitalWrite(yellow, HIGH);

digitalWrite(red, LOW);

delay(600);

else if (in <= 50 && in >= 25 )

digitalWrite(green, LOW);

digitalWrite(yellow, LOW);

digitalWrite(red, LOW);

delay(300);

digitalWrite(green, LOW);

digitalWrite(yellow, LOW);

digitalWrite(red, HIGH);

delay(300);

29
else if (in < 25)

digitalWrite(green, LOW);

digitalWrite(yellow, LOW);

digitalWrite(red, LOW);

delay(1000);

digitalWrite(green, LOW);

digitalWrite(yellow, LOW);

digitalWrite(red, LOW);

delay(1000);

Circuit Diagram:

30
Result:
Thus the simple circuit ultrasonic sensors using with Arduino was successfully
executed and the output was verified.

31
Ex. No:6.1
INTERFACING LCD DISPLAY WITH ARDUINO UNO

Aim:

To connect the simple circuit for display the name using LCD display
using Arduino UNO.

Hardware Required:

Components Quantity
Arduino Uno R3 1
MCP23008-based, 32 (0x20) LCD 16 x 2 1
(I2C)

Procedure:

 Connect SDA pin of the LCD to A4 and SCL pin to A5 on Arduino Uno R3.
 Ensure power (VCC) and ground (GND) pins of the LCD are connected to
5V and GND respectively.
 Define LCD address (usually 0x20) and dimensions (16x2) in Arduino
code.
 Create LiquidCrystal_I2C object with defined address and dimensions,
initialize LCD in setup().
 Use lcd.setCursor() and lcd.print() to display text on LCD in setup() or
loop().
 Upload code to Arduino, adjust text and connections as needed for your
Circuit.

32
Code:
#include <Adafruit_LiquidCrystal.h>

int seconds = 0;

Adafruit_LiquidCrystal lcd_1(0);

void setup()

lcd_1.begin(16, 2);

void loop()

lcd_1.setCursor(4, 0);

lcd_1.print(“S.NAREN”);

lcd_1.setCursor(10, 1);

lcd_1.print(21CS069);

delay(10); // Delay a little bit to improve simulation performance

33
Circuit Diagram:

Result:

Thus the simple circuit for display the name using LCD display
using Arduino UNO was executed successfully.

34
Ex.No:6.2
INTERFACING TEMPERATURE SENSOR WITH ARDUINO

Aim:

To connect the simple circuit for temperature measurement using LCD


display.

Hardware Required:

Components Quantity

Arduino Uno R3 1

MCP23008-based, 32 (0x20) LCD 16 x 2 (I2C) 1

Temperature Sensor [TMP36] 1

Procedure:
 Connect the 1K ohm resistor between the middle pin of the TMP36
temperature sensor and ground (GND) on the Arduino UNO.

 Connect the left pin of the TMP36 sensor to 5V on the Arduino UNO.

 Connect the right pin of the TMP36 sensor to analog pin A0 on the Arduino
UNO.

 Connect the anode (longer lead) of the red LED to digital pin 2, green LED to
pin 3, and yellow LED to pin 4.

 Connect the cathode (shorter lead) of each LED to a current-limiting resistor,


then to GND.

 Write code to read temperature from TMP36, and based on thresholds, turn on
respective LEDs to indicate temperature ranges.

35
Code:
void setup()

pinMode(A0, INPUT);

Serial.begin(9600);

pinMode(2, OUTPUT);

pinMode(3, OUTPUT);

pinMode(4, OUTPUT);

void loop()

baselineTemp = 40;

celsius = map(((analogRead(A0) - 20) * 3.04), 0, 1023, -40, 125);

fahrenheit = ((celsius * 9) / 5 + 32);

Serial.print(celsius);

Serial.print(" C, ");

Serial.print(fahrenheit);

Serial.println(" F");

if (celsius < baselineTemp)

digitalWrite(2, LOW);

digitalWrite(3, LOW);

digitalWrite(4, LOW);

36
}

if (celsius >= baselineTemp && celsius < baselineTemp + 10)

digitalWrite(2, HIGH);

digitalWrite(3, LOW);

digitalWrite(4, LOW);

if (celsius >= baselineTemp + 10 && celsius < baselineTemp + 20)

digitalWrite(2, HIGH);

digitalWrite(3, HIGH);

digitalWrite(4, LOW);

if (celsius >= baselineTemp + 20 && celsius < baselineTemp + 30)

digitalWrite(2, HIGH);

digitalWrite(3, HIGH);

digitalWrite(4, HIGH);

if (celsius >= baselineTemp + 30)

digitalWrite(2, HIGH);

digitalWrite(3, HIGH);

37
digitalWrite(4, HIGH);

delay(1000);

Circuit Diagram:

38
Result:
Thus the simple circuit for temperature measurement using LCD display was executed
successfully and the output was verified.

39
Ex. No:7
INTERFACING PIR SENSOR WITH ARDUINO

Aim:

To construct the circuit for interfacing a PIR (Passive Infrared) sensor


with an Arduino for motion detection and response.

Hardware Required:

Components Quantity
PIR Sensor 1
Arduino Uno R3 1
Red LED 1
1kohm resistor 1

Procedure:
.
 Insert the PIR sensor into the breadboard.

 Connect VCC to Arduino's 5V, GND to GND, and OUT to digital pin 2
(D2).
 Upload provided code to Arduino using Arduino IDE.

 Open Serial Monitor to observe motion detection messages.

 LED on pin 11 responds to motion detection.

 Optionally adjust sensor sensitivity using potentiometers.

 Secure components and integrate into project as needed.

40
Code:
int pir = 0;

void setup()

pinMode(5, INPUT);

Serial.begin(9600);

pinMode(13, OUTPUT);

void loop()

pir = digitalRead(5);

Serial.println(pir);

if (pir == 1)

digitalWrite(13, HIGH);

else

digitalWrite(13, LOW);

delay(10); // Delay a little bit to improve simulation performance

41
Circuit Diagram:

42
Result:
Thus the develop a interfacing PIR sensor with Arduino board was successfully
executed and the output was verified.

43
Ex. No:8
INTERFACING SERVO MOTOR WITH ARDUINO

Aim:

To connect the simple circuit for find angle servo motor using Arduino UNO.

Hardware Required:

Components Quantity
Arduino Uno R3 1
Positional Micro Servo 1

Procedure:

 Connect the servo motor to your Arduino Uno. Most servo motors have three wires:
power (usually red), ground (usually brown or black), and signal (usually orange or
yellow).
 Connect the power wire to the 5V pin on the Arduino Uno, the ground wire to any
ground pin, and the signal wire to any digital PWM (Pulse Width Modulation) pin.
 Develop the code to control the servo motor's position.
 After uploading the code, observe the behavior of the servo motor. Verify that it
rotates to the specified angles as programmed in your code.

44
Code:

#include <Servo.h>
Servo servoBase;
void setup()
{
servoBase.attach(A1);
servoBase.write(0); //asigno 0 al servo motor

}
void loop() {
for(int i=0; i<=180; i=i+10)

servoBase.write(i);

delay(550);
}

45
Circuit Diagram:

Result:
Thus the servo motor & setting servo motor with Arduino UNO was successfully
executed and the output was verified.

46
Ex. No:9
INTERFACING LDR SENSOR WITH ARDUINO

Aim:
To construct a simple circuit for Automatic Street Light by using Arduino UNO.

Hardware Required:

Components Quantity
Arduino Uno R3 1
Photo Resistor 1
1 kΩ Resistor 1
Red LED 1
300 Ω Resistor 1

Procedure:
 Connect the LDR (Light Dependent Resistor) sensor to your Arduino Uno. Wire
one leg of the LDR to the 5V pin on the Arduino Uno, and wire the other leg to
one leg of a resistor (any value between 1kΩ to 10kΩ is usually suitable). Connect
the other leg of the resistor to any ground (GND) pin on the Arduino Uno.
 Finally, connect the junction between the LDR and the resistor to an analog
input pin (e.g., A0) on the Arduino Uno.
 Develop the code to read data from the LDR sensor.
 After uploading the code, expose the LDR sensor to different levels off light and
observe the readings on the Serial Monitor (if set up).
 Verify that the sensor's output changes accordingly with varying light levels.

47
Code:

int input = 0;

void setup()

pinMode(A0, INPUT);

Serial.begin(9600);

pinMode(2, OUTPUT);

void loop()

input = analogRead(A0);

Serial.println(input);

if (input >= 300)

digitalWrite(2, HIGH);

else

digitalWrite(2, LOW);

delay(10); // Delay a little bit to improve simulation performance

48
Circuit Diagram:

49
Result:
Thus the simple circuit for Automatic Street Light by using Arduino Uno was
executed successfully and the output was verified.

50
Ex. No:10
SMART HOME AUTOMATION SYSTEM

Aim:
To construct a simple circuit for smart home automation system using Arduino UNO.

Hardware Required:

Components Quantity
Arduino Uno R3 1
Ultrasonic Distance Sensor 1
Positional Micro Servo 1
PIR Sensor 1
Blue LED 2
1 kΩ Resistor 1
Temperature Sensor [TMP36] 1
H-bridge Motor Driver 1
DC Motor 1
Blue led 2
Green led 2
Red led 2

Procedure:

 Connect ultrasonic sensor and Arduino board in to read the movement


 Write a code for reading analog values from smart home and upload it to the
Arduino Uno.
 Open the Serial Monitor in Arduino IDE to view the analog readings from the smart
home.
 Expose home temperature to varying levels to observe changes in readings.
 Check that the analog readings change proportionally with temperature levels,
giving higher readings.
51
 If the room detects any movement, the light (LED) will automatically be lighting.
If there is no movement in the room, then the light will remain off. (I used here
PIR for detecting movement and LED for Light)

Code:

const int pingPin = 7;


int servoPin = 8;
Servo servo1;
void setup() {
Serial.begin(9600);
servo1.attach(servoPin);
pinMode(2,INPUT);
pinMode(4,OUTPUT);
pinMode(11,OUTPUT);
pinMode(12,OUTPUT);
pinMode(13,OUTPUT);
pinMode(A0,INPUT);
digitalWrite(2,LOW);
digitalWrite(11,HIGH);

void loop() {
long duration, inches, cm;
pinMode(pingPin, OUTPUT);
digitalWrite(pingPin, LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
52
delayMicroseconds(5);
digitalWrite(pingPin, LOW);
pinMode(pingPin, INPUT);
duration = pulseIn(pingPin, HIGH);
inches = microsecondsToInches(duration);
cm = microsecondsToCentimeters(duration);
//Serial.print(inches);
//Serial.print("in, ");
//Serial.print(cm);
//Serial.print("cm");
//Serial.println();
//delay(100);
servo1.write(0);
if(cm < 40)
{
servo1.write(90);
delay(2000);
}
else
{
servo1.write(0);

// PIR with LED starts


int pir = digitalRead(2);

if(pir == HIGH)
{
digitalWrite(4,HIGH);
delay(1000);
53
}
else if(pir == LOW)
{
digitalWrite(4,LOW);
}

//temp with fan


float value=analogRead(A0);
float temperature=value*0.48;

Serial.println("temperature");
Serial.println(temperature);

if(temperature > 20)


{
digitalWrite(12,HIGH);
digitalWrite(13,LOW);
}
else
{
digitalWrite(12,LOW);
digitalWrite(13,LOW);
}
}

long microsecondsToInches(long microseconds) {


return microseconds / 74 / 2;
}

54
long microsecondsToCentimeters(long microseconds) {
return microseconds / 29 / 2;
}

Circuit Diagram:

55
Result:

Thus the simple circuit for home automation system using Arduino UNO was executed
successfully and the output was verified.

56

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy