You are on page 1of 38

PROJECT BASED

LEARNING-I LABORATORY

Page | 1
List of Experiments

S. No. Name of Experiments


1. Introduction to Arduino Uno

2 Write a code to display a sequence of digits 0-9 on seven segment display and
Arduino-Uno kit.
3. Design a Fire detection Alarm using Arduino.

4 Design a water level Indicator system using Arduino.


5 Design a light detector system using LDR and Arduino.
6 Design a soil moisture detection system using Arduino
7 Design a traffic control system using Arduino
8 Design a Bluetooth based smart door lock system using Arduino
9. Temperature and humidity Measurement with Arduino and DHT11 Sensor.
10. Experiment: Automatic car parking system project Using Arduino

Page | 2
1. Experiment – Introduction to Arduino Uno

Arduino Uno is a open-source microcontroller board based on the ATmega328p


microcontroller. It has 14 digital pins (out of which 6 pins can be used as PWM outputs),
6 analog inputs, on-board voltage regulators etc. Arduino Uno has 32KB of flash
memory, 2KB of SRAM and 1KB of EEPROM. It operates at a clock frequency of
16MHz. Arduino Uno supports Serial, I2C, SPI communication for communicating with
other devices. The table below shows the technical specification of Arduino Uno.

Microcontroller ATmega328p

Operating voltage 5V

Input Voltage 7-12V (recommended)

Digital I/O pins 14

Analog pins 6

Flash memory 32KB

SRAM 2KB

EEPROM 1KB

Clock speed 16MHz

Ref: https://components101.com/microcontrollers/arduino-uno

Page | 3
Page | 4
Arduino Uno Pinout Configuration

Pin Category Pin Name Details

Power Vin, 3.3V, 5V, GND Vin: Input voltage to Arduino when using an external
power source.
5V: Regulated power supply used to power
microcontroller and other components on the board.
3.3V: 3.3V supply generated by on-board voltage
regulator. Maximum current draw is 50mA.
GND: ground pins.

Reset Reset Resets the microcontroller.

Analog Pins A0 – A5 Used to provide analog input in the range of 0-5V

Input/Output Digital Pins 0 – 13 Can be used as input or output pins.


Pins

Serial 0(Rx), 1(Tx) Used to receive and transmit TTL serial data.

External 2, 3 To trigger an interrupt.


Interrupts

PWM 3, 5, 6, 9, 11 Provides 8-bit PWM output.

SPI 10 (SS), 11 (MOSI), 12 Used for SPI communication.


(MISO) and 13 (SCK)

Inbuilt LED 13 To turn on the inbuilt LED.

TWI A4 (SDA), A5 (SCA) Used for TWI communication.

AREF AREF To provide reference voltage for input voltage.

Page | 5
2. Experiment – Write a code to display a sequence of digits 0-9 on seven segment
display and Arduino-Uno kit.

This experiment is designed to explain the simple steps for installing IDE and interfacing
with Arduino-Uno. Students will establish the connection on bread board and write a code so
that they can display a sequence of digits like -0,2,3,1,6,5,7,8,9 on seven segment display.

Students will generate different sequences with different delays between the digits display.

Circuit Diagram :

Figure 2.1 Seven Segment Display


Code:

int f=13;
int g=12;
int e=11;
int d=10;
int c=9;
int b=8;
int a=7;

int de=1000;

void setup()
{
pinMode(f, OUTPUT);
pinMode(g, OUTPUT);
pinMode(e, OUTPUT);
pinMode(d, OUTPUT);
pinMode(c, OUTPUT);
Page | 6
pinMode(b, OUTPUT);
pinMode(a, OUTPUT);

// put your setup code here, to run once:

void loop()
{

digitalWrite(a,1);
digitalWrite(b,1);
digitalWrite(c,1);
digitalWrite(d,1);
digitalWrite(e,1);
digitalWrite(f,1);
digitalWrite(g,0);
delay(de); ///0

digitalWrite(a,0);
digitalWrite(b,1);
digitalWrite(c,1);
digitalWrite(d,0);
digitalWrite(e,0);
digitalWrite(f,0);
digitalWrite(g,0);
delay(de); ///1

digitalWrite(a,1);
digitalWrite(b,1);
digitalWrite(c,0);
digitalWrite(d,1);
digitalWrite(e,1);
digitalWrite(f,0);
digitalWrite(g,1);
delay(de); ///2

digitalWrite(a,1);
digitalWrite(b,1);
digitalWrite(c,1);
digitalWrite(d,1);
digitalWrite(e,0);
digitalWrite(f,0);
digitalWrite(g,1);
delay(de); ///3

digitalWrite(a,0);
digitalWrite(b,1);
digitalWrite(c,1);
digitalWrite(d,0);
digitalWrite(e,0);
digitalWrite(f,1);
digitalWrite(g,1);
delay(de); ////4

digitalWrite(a,1);
digitalWrite(b,0);
digitalWrite(c,1);
digitalWrite(d,1);
digitalWrite(e,0);
Page | 7
digitalWrite(f,1);
digitalWrite(g,1);
delay(de); /////5

digitalWrite(a,0);
digitalWrite(b,0);
digitalWrite(c,1);
digitalWrite(d,1);
digitalWrite(e,1);
digitalWrite(f,1);
digitalWrite(g,1);
delay(de); /////6

digitalWrite(a,1);
digitalWrite(b,1);
digitalWrite(c,1);
digitalWrite(d,0);
digitalWrite(e,0);
digitalWrite(f,0);
digitalWrite(g,0);
delay(de); /////7

digitalWrite(a,1);
digitalWrite(b,1);
digitalWrite(c,1);
digitalWrite(d,1);
digitalWrite(e,1);
digitalWrite(f,1);
digitalWrite(g,1);
delay(de); /////8

digitalWrite(a,1);
digitalWrite(b,1);
digitalWrite(c,1);
digitalWrite(d,0);
digitalWrite(e,0);
digitalWrite(f,1);
digitalWrite(g,1);
delay(de); /////9

digitalWrite(a,1);
digitalWrite(b,1);
digitalWrite(c,1);
digitalWrite(d,1);
digitalWrite(e,1);
digitalWrite(f,1);
digitalWrite(g,0);
delay(de); /////0

// put your main code here, to run repeatedly:

Page | 8
3. Experiment – Design a Fire detection Alarm using Arduino.

Fire Alarm Systems are very common in commercial building and factories, these devices
usual contain a cluster of sensors that constantly monitors for any flame, gas or fire in the
building and triggers an alarm if it detects any of these. One of the simplest way to detect
fire is by using an IR Flame sensor, these sensors have an IR photodiode which is sensitive
to IR light. Now, in the event of a fire, the fire will not only produce heat but will also emit
IR rays, yes every burning flame will emit some level of IR light, this light is not visible to
human eyes but our flame sensor can detect it and alert a microcontroller like Arduino that a
fire has been detected.

Flame Sensor
A flame detector is a sensor designed to detect and respond to the presence of a flame or
fire. Responses to a detected flame depend on the installation but can include sounding an
alarm, deactivating a fuel line (such as a propane or a natural gas line), and activating a fire
suppression system. The IR Flame sensor used in this project is shown below, these sensors
are also called Fire sensor module or flame detector sensor sometimes.

Figure 3.1 Flame Sensor

There are different types of flame detection methods. Some of them are: Ultraviolet detector,
near IR array detector, infrared (IR) detector, Infrared thermal cameras, UV/IR detector etc.

When fire burns it emits a small amount of Infra-red light, this light will be received by the
Photodiode (IR receiver) on the sensor module. Then we use an Op-Amp to check for a
change in voltage across the IR Receiver, so that if a fire is detected the output pin (DO) will
give 0V(LOW), and if the is no fire the output pin will be 5V(HIGH).

In this project, we are using an IR based flame sensor. It is based on the YG1006 sensor
which is a high speed and high sensitive NPN silicon phototransistor. It can detect infrared
light with a wavelength ranging from 700nm to 1000nm and its detection angle is about 60°.
The flame sensor module consists of a photodiode (IR receiver), resistor, capacitor,
potentiometer, and LM393 comparator in an integrated circuit. The sensitivity can be
adjusted by varying the onboard potentiometer. Working voltage is between 3.3v and 5v DC,
with a digital output. A logic high on the output indicates the presence of flame or fire. A
logic low on output indicates the absence of flame or fire.
Page | 9
Below is the Pin Description of the Flame sensor Module:

Pin Description

Vcc 3.3 – 5V power supply

GND Ground

Dout Digital output

Applications of flame sensors

 Hydrogen stations
 Combustion monitors for burners
 Oil and gas pipelines
 Automotive manufacturing facilities
 Nuclear facilities
 Aircraft hangars
 Turbine enclosures

Components Required

 Arduino Uno (any Arduino board can be used)


 Flame sensor module
 LED
 Buzzer
 Resistor
 Jumper wires

Circuit Diagram
The below image is the Arduino fire sensor circuit diagram, it shows how to interface the
fire sensor module with Arduino.

Page | 10
Figure 3.2 Working Model of Flame Sensor with Arduino

Working of Flame Sensor with Arduino

The flame sensor detects the presence of fire or flame based on the Infrared (IR)
wavelength emitted by the flame. It gives logic 1 as output if a flame is detected, otherwise,
it gives logic 0 as output. Arduino Uno checks the logic level on the output pin of the sensor
and performs further tasks such as activating the buzzer and LED, sending an alert message.

The flame sensor is connected to digital pin 4 of Arduino. The buzzer is connected to digital
pin 8 of Arduino. LED is connected to digital pin 7 of Arduino.

Page | 11
Figure 3.3 Circuit Diagram of Flame Sensor with Arduino

Code:

int buzzer = 8;

int LED = 7;

int flame_sensor = 4;

int flame_detected;

void setup()

Serial.begin(9600);

pinMode(buzzer, OUTPUT);

pinMode(LED, OUTPUT);

pinMode(flame_sensor, INPUT);

void loop()

Page | 12
{

flame_detected = digitalRead(flame_sensor);

if (flame_detected == 1)

Serial.println("Flame detected...! take action immediately.");

digitalWrite(buzzer, HIGH);

digitalWrite(LED, HIGH);

delay(200);

digitalWrite(LED, LOW);

delay(200);

else

Serial.println("No flame detected. stay cool");

digitalWrite(buzzer, LOW);

digitalWrite(LED, LOW);

delay(1000);

Ref: https://circuitdigest.com/microcontroller-projects/arduino-flame-sensor-interfacing

4. Experiment – Design a water level Indicator system using Arduino.


Water level sensor will give an indication of the water level in water tank. It helps to know the
water level so that we can turn water pump ON/OFF as per the need.

In this experiment, we learn to interface the water level sensor with the Arduino UNO to
Page | 13
measure the water level of the water tank. If the water level will be low it will turn ON the red
LED that’s indicate to turn on the pump, if the water level is high it will turn on a green LED
that says to turn off the pump. In normal water level a yellow LED will be on.

Components Required

1. Water level sensor


2. Arduino Uno
3. Connecting Wires
4. LEDs
5. Resistors
6. Breadboard

Pin Description for Water Level Sensor

Figure 4.1 Pinout of Water Level Sensor

S (signal pin) is an analog output that will be connected to the analog pin of the Arduino.

+VCC is powering pin of the sensor. The approved input voltage is 3.3v to 5v.

-GND is simply a ground connection.

How To Calibrate Water Level Sensor

Page | 14
Figure 4.2 Calibration of Water Level Sensor

Interfacing Diagram
Connect the circuit as shown in the following diagram.

Figure 4.3 Interfacing of Water Level Sensor with Arduino

 In this interfacing, connect the signal pin of the sensor to the A0 of the
Arduino.
 Connect the VCC of the sensor to the Digital pin 7 of the Arduino.
 Connect GND of the sensor to the Ground of the Arduino.
 Connect the cathode of RED, YELLOW, GREEN LED to the 2,3,4
digital pin of the Arduino respectively.
 Connect all anodes of the LED commonly to the GND pin of the
Arduino.

To represent our threshold level there are two variables that are used as the Upper
Threshold & Lower Threshold. Below threshold level, red LED will turn on, above

Page | 15
threshold level green LED will turn on, in between these two levels yellow led will turn on.

Code:

/* Change these values based on your calibration values */


int lowerThreshold = 420;
int upperThreshold = 520;

// Sensor pins
#define sensorPower 7
#define sensorPin A0

// Value for storing water level


int val = 0;

// Declare pins to which LEDs are connected


int redLED = 2;
int yellowLED = 3;
int greenLED = 4;

void setup() {
Serial.begin(9600);
pinMode(sensorPower, OUTPUT);
digitalWrite(sensorPower, LOW);

// Set LED pins as an OUTPUT


pinMode(redLED, OUTPUT);
pinMode(yellowLED, OUTPUT);
pinMode(greenLED, OUTPUT);

// Initially turn off all LEDs


digitalWrite(redLED, LOW);
digitalWrite(yellowLED, LOW);
digitalWrite(greenLED, LOW);
}

void loop() {
int level = readSensor();

if (level == 0) {
Serial.println("Water Level: Empty");
digitalWrite(redLED, LOW);
digitalWrite(yellowLED, LOW);
digitalWrite(greenLED, LOW);
}
Page | 16
else if (level > 0 && level <= lowerThreshold) {
Serial.println("Water Level: Low");
digitalWrite(redLED, HIGH);
digitalWrite(yellowLED, LOW);
digitalWrite(greenLED, LOW);
}
else if (level > lowerThreshold && level <= upperThreshold) {
Serial.println("Water Level: Medium");
digitalWrite(redLED, LOW);
digitalWrite(yellowLED, HIGH);
digitalWrite(greenLED, LOW);
}
else if (level > upperThreshold) {
Serial.println("Water Level: High");
digitalWrite(redLED, LOW);
digitalWrite(yellowLED, LOW);
digitalWrite(greenLED, HIGH);
}
delay(1000);
}

//This is a function used to get the reading


int readSensor() {
digitalWrite(sensorPower, HIGH);
delay(10);
val = analogRead(sensorPin);
digitalWrite(sensorPower, LOW);
return val;
}

Reference-

https://robu.in/water-level-indicator-interfacing-with-arduino-connection-and-code/

5.Experiment – Design a light detector system using LDR and Arduino.


Page | 17
Monitoring the output of a light-dependent resistor, or photoresistor, allows the Arduino to
know how light or dark it is. When the light falls below a certain level, the Arduino turns on
a couple of LEDs.
A light-dependent resistor, or photoresistor, is a sensor whose resistance decreases as the
amount of light falling on it increases. When it is dark, the resistance of a photoresistor may
be as high as a few MΩ. When it is light, however, the resistance of a photoresistor may be
as low as a few hundred ohms.
In this experiment, we will connect a photoresistor to an Arduino analog input and read the
value with the analogRead() function. Depending on the value the Arduino reads, the
program will then set pin 3 HIGH or LOW to turn on or turn off the LED night lights. The
threshold value is 150. When the analog value read is less than 150, the Arduino will turn the
LEDs on. When the analog value it reads is below 150, the Arduino will turn the LEDs off.

Arduino Light Sensor Hardware Required

 1 x photoresistor
 2 x LED
 2 x 470 ohm resistors
 1 x 1 kohm resistors
 1 x Arduino Mega2560
 1 x breadboard
 jumper wires

Wiring Diagram
You connect the components as shown in the diagram below. Connect the LEDs to pin 3 of
the Arduino. The two 470 ohm resistors are current limiting resistors. One lead of the photo
resistor is connected to 5V, the other to one lead of the 1 kohm resistor. The other lead of the
10 kohm resistor is connected to ground. This forms a voltage divider, whose output is
connected to pin A1 of the Arduino. As the light impinging on the photoresistor gets
stronger, the resistance decreases, and the voltage output of the divider increase. The reverse
happens, when the impinging light gets weaker.

Circuit Diagram:

Page | 18
Figure Circuit Diagram for Light detector system using LDR

Setup:

1. Connect one of the two terminals of LDR to 5V and other one to the GND
through a one kilo ohm resistor.
2. Connect one end of a wire to analog pin A1 and other to 1K resistor’s non-
grounded terminal.
3. Connect two LEDs in parallel, both through a 470 ohm resistor and with negative
terminal grounded as shown in above circuit diagram.
4. Connect pin 3 to the positive terminals of LEDs through 470 ohm resistors.
5. Connect all the grounded terminals to Arduino’s GND pin.
6. Connect the Arduino using Arduino USB cable and upload the program to
Arduino using Arduino IDE software.
7. Provide power to the Arduino board using power supply, battery or USB cable.

If the room is lighted, the LEDs should not light. Try getting them to turn on it by covering
the photoresistor with your hand. Remove your hand and observe that they turn off again.

Code:
const int led=3; // variable which stores pin number

void setup()

Page | 19
{
pinMode(led, OUTPUT); //configures pin 3 as OUTPUT
}

void loop()
{
int sensor_value = analogRead(A0);
if (sensor_value < 150)// the point at which the state of LEDs change
{
digitalWrite(led, HIGH); //sets LEDs ON
}
else
{
digitalWrite(led,LOW); //Sets LEDs OFF
}

Page | 20
EXPERIMENT – 6 :

SOIL MOISTURE DETECTION USING ARDUINO

6.1 AIM:

To design a soil moisture detection system using Arduino

6.2 APPARATUS:

S Name of the equipment Quantity


No
1 Arduino Uno 1
2 Soil Moisture Sensor 1
3 16×2 LCD Display 1
4 10KΩ Potentiometer (for LCD) 1
5 Hook up Wires As required
6 Bread Board 1
7 Computer with Arduino IDE software 1
8 Connecting wires As
required
9 Test setup with 3 cups of soil

6.3 INTRODUCTION

Soil moisture is basically the content of water present in the soil. This
can be measured using a soil moisture sensor which consists of two
conducting probes that act as a probe. It can measure the moisture
content in the soil based on the change in resistance between the two
conducting plates. The resistance between the two conducting plates
varies in an inverse manner with the amount of moisture present in the
soil. The main component of the experiment (apart from the Arduino
UNO) is the Soil Moisture Sensor. It consists of two parts: The main
Sensor and the Control Board. Sensor part of the Soil Moisture Sensor
consists of a couple of conductive probes that can be used to measure the
volumetric content of water in soil. Coming to the control board, it is
made up of LM393 IC, which is a voltage comparator. The board also
consists of all the necessary components like connectors, LEDs, resistors
etc. to measure the Soil Moisture. Additionally, there is an option to
Page | 21
adjust the sensitivity of the module with the help of a Potentiometer.

Figure 6.1 Soil Moisture Sensor

Figure 6.2. Pin diagram of Control Module

6.4 CIRCUIT DIAGRAM:

Figure: 6.3 Soil moisture connection with Arduino Module


Page | 22
6.5 CODE

int WET= 3;
int DRY= 2;
int Sensor= 0; // Soil Sensor input at Analog PIN A0
int value= 0;

void setup() {
Serial.begin(9600);
pinMode(WET, OUTPUT);
pinMode(DRY, OUTPUT);
delay(2000);
}

void loop() {
Serial.print("MOISTURE LEVEL : ");
value= analogRead(Sensor);
value= value/10;
Serial.println(value);
if(value<50)
{
digitalWrite(WET, HIGH);
}
else
{
digitalWrite(DRY,HIGH);
}
delay(1000);
digitalWrite(WET,LOW);
digitalWrite(DRY, LOW);
}

6.6 PROCEDURE

6.6.1 Open the Arduino IDE in computer and write the program. Soil
Moisture Sensor consists Of four Pins i.e, A0, D0, GND and Vcc.
Connect these Pins to the Arduino with Jumping Wires and Do not
connect the digital Pin i.e, D0 to the Arduino. Connect the Pins and
make sure that they are connected properly. Connect the Led to the
Arduino to one of the digital Pins.

6.6.2 Before going to the code, let us see the working of the soil moisture
sensor. The soil moisture sensor consists of two probes which are used
to measure the volumetric content of water. The two probes allow the
Page | 23
current to pass through the soil and then it gets the resistance value to
measure the moisture value. When there is more water, the soil will
conduct more electricity which means that there will be less resistance.
Therefore, the moisture level will be higher. Dry soil conducts
electricity poorly, so when there will be less water, then the soil will
conduct less electricity which means that there will be more resistance.
Therefore, the moisture level will be lower. This sensor can be
connected in two modes; Analog mode and digital mode.

6.6.3 Connect the Arduino to the PC and open the ARDUINO IDE and write
the code. The code is very simple to understand and basic. Use the
analogRead function to read the values for the sensor. Try to do the
code by your own, if you have any doubts regarding the code, the code
is shown below.

6.6.4 The Led glows if the moisture is less than the required and doesn’t glow
if the moisture level is more. The output of the Project is shown below
with some pics and a video.

6.7 RESULT

Page | 24
EXPERIMENT – 7

TRAFFIC SIGNAL CONTROL

7.1 AIM:

To design a traffic control system using IOT

7.2 APPARATUS:

S Name of the equipment Quantity


No
1 Arduino and ESP8266 wi fi module 1
2 16 x 2 LCD display 1
3 Proximity sensor 1
4 LEDs (R,Y,G) 6
5 Computer with Arduino IDE software 1
6 Connecting wires As
required

7.3 CIRCUIT DIAGRAM:

Page | 25
Figure: 7.1Circuit Diagram

7.4 CODE

// light
one int
red1 = 10;
int yellow1 = 9;

Page | 26
int green1 = 8;
// light
two int
red2 = 13;
int yellow2 =
12; int
green2 = 11;
void setup()
{
// light one
pinMode(red1,
OUTPUT);
pinMode(yellow1,
OUTPUT);
pinMode(green1,
OUTPUT);
// light two
pinMode(red2,
OUTPUT);
pinMode(yellow2,
OUTPUT);
pinMode(green2,
OUTPUT);
}
void loop()
{
changeLight
s();
delay(15000
);
}
void changeLights()
{
// turn both yellows
on digitalWrite(green1,
LOW);
digitalWrite(yellow1,
HIGH);
digitalWrite(yellow2,
HIGH); delay(5000);
// turn both yellows off, and opposite
green and red digitalWrite(yellow1,
LOW);
digitalWrite(red1,
HIGH);
digitalWrite(yellow2,
LOW);
digitalWrite(red2,
Page | 27
LOW);
digitalWrite(green2,
HIGH); delay(5000);
// both yellows on
again
digitalWrite(yellow1,
HIGH);
digitalWrite(yellow2,
HIGH);
digitalWrite(green2,
LOW); delay(3000);
// turn both yellows off, and opposite
green and red digitalWrite(green1,
HIGH);
digitalWrite(yellow1,
LOW);
digitalWrite(red1,
LOW);
digitalWrite(yellow2,
LOW);
digitalWrite(red2,
HIGH); delay(5000);
}

7.5 PROCEDURE

7.5.1 Make the connection as per the electrical circuit diagram


7.5.2 Open the Arduino IDE in computer and write the program.
7.5.3 Compile the program for any errors and upload it to the Arduino.
7.5.4 Observe the status of traffic light on junctions at traffic control room through
IOT.

Page | 28
7.6 RESULT:

7.7 PRE LAB VIVA QUESTIONS:

7.7.1 What is red light indicates in traffic signals?


7.7.2 What is yellow light indicates in traffic signals?
7.7.3 What is green light indicates in traffic signals?
7.7.4 What do you mean by free left at signal junctions?
7.7.5 What are the precautions to be taken while driving?

7.8 POST LAB VIVA QUESTIONS:

7.8.1 What is meant by LED?


7.8.2 How the colour for an LED will be changes?
7.8.3 What are the operating voltages of red, yellow and green LEDs?
7.8.4 What are the parameters that can be controlled through IOT in this experiment?
7.8.5 Where this traffic signal controlling system with IOT is preferable?

Page | 29
EXPERIMENT – 8 : Bluetooth based Smart Door lock system using Arduino

8.1 AIM:

Bluetooth based Smart Door Lock System Using Arduino

8.2APPARATUS:

S Name of the equipment Quantity


No
1 Arduino Uno 1
2 Nodemcu ESP8266 1
3 Motor Driver Circuit 1
4 Door Lock 1

Software Tools
1 Computer with Arduino IDE software

2 Embedded C

8.3Introduction

Nowadays the home security system is very poor. This project is consists
of a smart door lock system in this we developed on a great solution to
improve the home safety system. Arduino IDE software in this we used
Bluetooth devices to operate the door lock-in the home. The
microcontroller is connected to l293d driver IC that driver IC is used to
operate the DC Gearmotor in forward(Open) and backward (Close) and the
motor is controlling the door lock. In this method, all data are controlling
by Bluetooth android application in that app we are sending the data
through Bluetooth to control the home door lock one is open and another
one close form the application. Nobody can hack the system it was a
closed-loop and most secure system. n this project, we are controlling the
door lock in the Bluetooth android application. Form the Android
application we are sending the information to open and close the door lock.
When the data was received for the android app the Arduino Uno has
transferred the information to the l293d driver that the driver controls the
dc gear motor. When we pass the ‘F’ character door lock will open. if we
Page | 30
pass the ‘R ‘ character door lock will close. This method is called a
Bluetooth smart door lock system.

8.4 Circuit Diagram

Figure 8.1 Circuit diagram for Bluetooth based smart door lock system

8.5RESULT:

Page | 31
9. Experiment : Temperature and humidity Measurement with Arduino and DHT11
Sensor.

9.1AIM:
Temperature and humidity Measurement with Arduino and DHT11

9.2APPARATUS:

S No Name of the equipment Quantity


1 Arduino Uno 1
2 DHT11 Temperature Sensor 1
3 16X2 LCD 1

9.3 Introduction

A mixed temperature and humidity sensor DHT11 is utilized with Arduino uno to
develop this project. Working of this project depends on single-wire serial
communication. The first Arduino transmits a start signal to the DHT module and
then DHT presents a response signal including temperature and humidity data.
Arduino gathers and removes in two parts one is humidity and the second one is
temperature and then sends them to 16x2 LCD. Arduino gathers and removes in two
parts one is humidity and the second one is temperature and then sends them to 16x2
LCD. In this project, we have utilized a sensor module DHT11. The DHT11 sensor
module is a linked module for sensing humidity and temperature which presents a
calibrated digital output signal. DHT11 delivers us a specific value of humidity and
temperature and assures high security and long-term immobility. DHT11 module
operates on serial communication. This module transfers data in the form of the pulse
train of a specific time period. Before sending data to Arduino, it requires some
initialize command with a time delay. And the whole process time is about 4ms.

9.4 Circuit Diagram

The DHT11 uses just one signal wire to transmit data to the Arduino. Power comes
from separate 5V and ground wires. A 10K Ohm pull-up resistor is needed between
the signal line and 5V line to make sure the signal level stays high by default (see
the datasheet for more info).
There are two different versions of the DHT11 you might come across. One type
has four pins, and the other type has three pins and is mounted to a small PCB. The

Page | 32
PCB mounted version is nice because it includes a surface mounted 10K Ohm pull
up resistor for the signal line. Here are the pinouts for both versions:

Figure 9.1 : DHT11 Sensor

Figure 9.2 : DH11 Connection with Arduino Board

9.5 Code

// Example testing sketch for various DHT humidity/temperature sensors


// Tech at Home

#include "DHT.h"

#define DHTPIN 2 // what pin we're connected to

// Uncomment whatever type you're using!


#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT22 // DHT 22 (AM2302)

Page | 33
//#define DHTTYPE DHT21 // DHT 21 (AM2301)

// Connect pin 1 (on the left) of the sensor to +5V


// NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1
// to 3.3V instead of 5V!
// Connect pin 2 of the sensor to whatever your DHTPIN is
// Connect pin 4 (on the right) of the sensor to GROUND
// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor

// Initialize DHT sensor.


// Note that older versions of this library took an optional third parameter to
// tweak the timings for faster processors. This parameter is no longer needed
// as the current DHT reading algorithm adjusts itself to work on faster procs.
DHT dht(DHTPIN, DHTTYPE);

void setup() {
Serial.begin(9600);
Serial.println("DHTxx test!");

dht.begin();
}

void loop() {
// Wait a few seconds between measurements.
delay(2000);

// Reading temperature or humidity takes about 250 milliseconds!


// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
float h = dht.readHumidity();
// Read temperature as Celsius (the default)
float t = dht.readTemperature();
// Read temperature as Fahrenheit (isFahrenheit = true)
float f = dht.readTemperature(true);

// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println("Failed to read from DHT sensor!");
return;
}

// Compute heat index in Fahrenheit (the default)


float hif = dht.computeHeatIndex(f, h);
// Compute heat index in Celsius (isFahreheit = false)
float hic = dht.computeHeatIndex(t, h, false);

Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(t);
Serial.print(" *C ");
Serial.print(f);

Page | 34
Serial.print(" *F\t");
Serial.print("Heat index: ");
Serial.print(hic);
Serial.print(" *C ");
Serial.print(hif);
Serial.println(" *F");
}

9.6 Result :

10 . Experiment: Automatic car parking system project Using Arduino

Page | 35
10.1 AIM

Automatic car parking system project Using Arduino.

10.2 APPARATUS:

S No Name of the equipment Quantity


1 Arduino Uno 1
2 Two IR sensors 2
3 Servo motor 1
4 Jumper wires and a breadboard As Required

5 USB cable for uploading the code 1

3 16X2 LCD 1

10.3. Introduction

This system is capable of finding the empty slots that are available for parking
automatically. If the slot is empty in the automated car parking the new vehicles are
allowed to enter the parking else the entrance is blocked by using the servo barrier in
case no empty slot is found by the system. The visitors can see the status for the
availability of the free space outside the parking on a 16×2 LCD.

10.4. Circuit Diagram

Figure 10.1 Automatic car parking system using Arduino


10.5. Code

Page | 36
// I2C LIBRARY
//https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
#include <Servo.h>
Servo myservo1;
int IR1 = 4; // IR Sensor 1
int IR2 = 7; // IR Sensor 2
int Slot = 4; //Enter Total number of parking Slots
int flag1 = 0;
int flag2 = 0;
void setup()
{
lcd.init();
lcd.backlight();
pinMode(IR1, INPUT);
pinMode(IR2, INPUT);
myservo1.attach(9);
myservo1.write(100);
lcd.setCursor (0,0);
lcd.print(" ARDUINO ");
lcd.setCursor (0,1);
lcd.print(" PARKING SYSTEM ");
delay (2000);
lcd.clear();
}
void loop(){
if(digitalRead (IR1) == LOW && flag1==0){
if(Slot>0){flag1=1;
if(flag2==0){myservo1.write(0); Slot = Slot-1;}
}else{
lcd.setCursor (0,0);

lcd.print(" SORRY 🙁 ");


lcd.setCursor (0,1);
lcd.print(" Parking Full ");
delay (3000);
lcd.clear();
}
}
if(digitalRead (IR2) == LOW && flag2==0){flag2=1;
if(flag1==0){myservo1.write(0); Slot = Slot+1;}
}
if(flag1==1 && flag2==1){
delay (1000);
myservo1.write(100);
flag1=0, flag2=0;
}
lcd.setCursor (0,0);
lcd.print(" WELCOME! ");
lcd.setCursor (0,1);

Page | 37
lcd.print("Slot Left: ");
lcd.print(Slot);
}

10.6 Result

Page | 38

You might also like