0% found this document useful (0 votes)
310 views25 pages

ES Practical

This practical demonstrates using a humidity sensor with Arduino to measure and monitor humidity levels. The sensor outputs a voltage based on humidity that is read by the Arduino analog pin and converted to a humidity percentage. The reading is then printed out on the serial monitor.

Uploaded by

Fake Account
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
310 views25 pages

ES Practical

This practical demonstrates using a humidity sensor with Arduino to measure and monitor humidity levels. The sensor outputs a voltage based on humidity that is read by the Arduino analog pin and converted to a humidity percentage. The reading is then printed out on the serial monitor.

Uploaded by

Fake Account
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

Smt.

Sushiladevi Deshmukh College of Art’s ,


Science & Commerce
(Affiliated to University of Mumbai)

Sector – 04, Airoli, Navi Mumbai-400708

Certificate
This is to certify that Mr. / Miss
Roll No. of B.Sc. IT Semester IV has successfully completed all the
Practical Work in the Subject of “Introduction to Embedded Systems” during the
academic year 2023-2024 under the guidance of Prof.Mrs.Vanita Sharma being
the partial requirement for the fulfillment of the curriculum of Degree of Bachelor
of Science in Information Technology Practical Exam.

Signature of Subject Incharge Head of Department


INDEX
Sr
Date Practical Remarks
No.

- Introduction to Arduino

1 Blinking of LED’s

2 Program using Light Sensitive Sensors

3 Program using Temperature sensors

4 Program using Humidity sensors

5 Program using Ultrasonic Sensors

6 Programs using Servo Motors

Programs using digital infrared


7
motion sensors

8 Programs using Gas sensors


Introduction to Embedded System 2023 - 24

INTRODUCTION TO ARDUINO:

Arduino is an open-source microcontroller that enables


programming and interaction; it is programmed in C/C++ with an
Arduino library to allow it to access the hardware.
This allows for more flexible programmability and the ability to use
electronics that can interface with Arduino. Because Arduino is
open source, the plans for the circuits are available online for free
to anyone who wants to use and create their own board based on
the schematics, as long as they share what they create.
This allows for considerable customizability in projects; till date,
users have built Arduinos of different sizes, shapes, and power
levels to control their projects.

The Arduino board is shown below:

SY BSC IT
Introduction to Embedded System 2023 - 24

THE COMPONENTS OF ARDUINO UNO R3:

Tx and Rx are serial UART pins used for RS-232 and USB
communications.

I2C is another serial communications method that uses a bi-


directional data line (SDA) and a clock line (SCL).

SPI is another serial communications method that uses one line for
the master to transmit (MOSI—Master Out Slave In), another for the
master to receive (MISO), and a third as a clock (SCK).

A/D, the Analog to Digital input, converts an analog voltage into a


digital representation.

PWM (Pulse Width Modulator) is used to create a square wave with


a specific duty cycle (high time vs low time).

ICSP is the In-Circuit Serial Programming—another way to


program the processor.

VCC is the voltage supplied to the processor (+5VDC regulated from


a higher input voltage). 3.3VDC is a regulated voltage (from the
higher input voltage) for peripherals.

IOREF provides a voltage reference so shields can select the


proper power source.

AREF is a reference INPUT voltage used by the A/D’s.

GND is the ground reference.

RESET resets the processor (and some peripherals)

SY BSC IT
Introduction to Embedded System 2023 - 24

PRACTICAL 1: BLINKING OF LEDS

Aim:
To study the basics of Arduino circuits and bread-boarding blinking
of LEDs

Components Used:
Arduino UNO
Breadboard
LED
Resistor (330 Ω)

Theory:
Arduino UNO is used to blink the LED continuously, we connect pin
13 to the anode of the LED and the cathode of the LED is connected
to a resistor (330 Ω) to limit the current passing through the LED.
If a large current flows through the LED then it may damage the
LED (in real world environment).
The other end of the LED is terminated to the ground connection of
the Arduino to complete the Circuit.

SY BSC IT
Introduction to Embedded System 2023 - 24

Code:
// C++ 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)
}

Output:

SY BSC IT
Introduction to Embedded System 2023 - 24

PRACTICAL 2: PROGRAM USING LIGHT-SENSITIVE SENSORS

Aim:
To study the working of Light sensors using Arduino Simulation
Environment TinkerCAD.

Components:
Arduino UNO
LED
Photodiode
Resistors

Theory:
The goal of this practical is to create a system that can
automatically control the brightness of an LED based on the light
detected by a photodiode.
This project leverages the principles of light sensing and feedback
control.

Working Principle:
The working principle of a photoelectric sensor is based on the
photoelectric effect. i.e., whenever an object is exposed to light or
whenever a light incident on a material then it emits some
electrons.
These electrons excite the phototransistor or receiver which
generates a voltage or current signal proportionally to the intensity
of light.
If an object interrupts the light, then the electrons received by the
phototransistor will be reduced. Which further changes the output
voltage and current signal.
Then the sensor senses the change and reacts accordingly. This
change in output signal indicates the presence or absence of an
object.

SY BSC IT
Introduction to Embedded System 2023 - 24

Pin Connections:

Arduino Photoresistor LED


5V Right pin
GND Left pin through a
(Power) series resistors
A0 Left pin
Pin 9 Anode
Cathode through
GND (digital)
series resistors

Code:
int lightSensorValue = 0; // Variable to store the light sensor
reading
void setup() {
pinMode(A0, INPUT); // Set A0 pin as an input for the light sensor
pinMode(9, OUTPUT); // Set pin 9 as an output to control the LED
Serial.begin(9600); // Initialize serial communication at 9600 baud
}
void loop() {
lightSensorValue = analogRead(A0); // Read the light sensor value
Serial.println(lightSensorValue); // Print the sensor value to the
Serial Monitor
int ledBrightness = map(lightSensorValue, 0, 1023, 0, 255); // Map
the sensor value to LED brightness
analogWrite(9, ledBrightness); // Control LED brightness based on
the sensor reading
delay(100); // Wait for 100 milliseconds before the next loop
iteration
}

SY BSC IT
Introduction to Embedded System 2023 - 24

Output:

SY BSC IT
Introduction to Embedded System 2023 - 24

PRACTICAL 3: PROGRAM USING TEMPERATURE SENSORS

Aim:
To study the working of Temperature sensors using Arduino
Components: Arduino UNO, Temperature Sensor TMP 36 Theory:
The temperature sensor in Arduino converts the surrounding
temperature to voltage. It further converts the voltage to Celsius,
Celsius to Fahrenheit, and prints the Fahrenheit temperature on
the LCD screen.

We will use a temperature sensor (TMP 36) of low voltage. Such


sensors are also stable while dealing with large capacitive loads.
It is also suitable for automotive applications. It typically has three
pins: VCC, GND, and OUT.

The sensor's output voltage increases by 10 mV per degree Celsius.


At 25°C, it outputs 750 mV.

Working :
The measurement of the temperature sensor is about the coolness
or hotness of an entity.
The working of the sensor is the voltage that reads across to the
diode. If increment in voltage, then the temperature increases and
there is a voltage decrement between the transistor’s terminals of
the emitter & base. That data is saved by the sensor.
If the voltage difference is amplified, then an analog signal is
generated by the device, and it is directly proportional to the
temperature.

SY BSC IT
Introduction to Embedded System 2023 - 24

Pin Connections:

Arduino TMP 36 Sensor

5V Left pin

GND Right pin

A1 Center pin

Code:
char degree = 176; // ASCII Value of Degree
const int sensor = A1;
void setup()
{
pinMode(sensor, INPUT);
Serial.begin(9600);
}
void loop()
{
int tmp = analogRead(sensor); // Read data from the sensor. This
voltage is stored as a 10-bit number.
float voltage = (tmp * 5.0) / 1024; // Convert the 10-bit number to a
voltage reading.
float tmpCel = (voltage - 0.5) * 100.0; // Convert voltage to Celsius.
Serial.print("Celsius: ");
Serial.print(tmpCel);
Serial.println(degree);
delay(1000);
}

SY BSC IT
Introduction to Embedded System 2023 - 24

Output:

SY BSC IT
Introduction to Embedded System 2023 - 24

PRACTICAL 4: PROGRAM USING HUMIDITY SENSORS

Aim:
To study the working of Humidity sensors using Arduino
Components: Arduino UNO, Potentiometer (wiper).

Theory:
Humidity Sensor is one of the most important devices that has been
widely in consumer, industrial, biomedical, and environmental etc.
applications for measuring and monitoring Humidity.
Humidity is defined as the amount of water present in the
surrounding air. This water content in the air is a key factor in the
wellness of mankind.
Potentiometer as a Sensor:
A potentiometer, often referred to as a "pot," is a variable resistor
with three terminals.
It consists of a resistive track and a wiper that moves along the
track. By adjusting the wiper's position, you can vary the
resistance.
In this demonstration, the potentiometer is used to simulate a
variable sensor input.

Arduino:
Arduino is a versatile microcontroller platform commonly used for
various electronic projects.
It can read analog voltage levels from sensors, including
potentiometers, and convert them into digital values for
processing.

Pin Connections:

Arduino Potentiometer
5v Left pin
GND Right pin
A1 Center pin

SY BSC IT
Introduction to Embedded System 2023 - 24

Code:
const int analogIn = A1; // Connect the humidity sensor to this pin
int humiditySensorOutput = 0;
void setup()
{
Serial.begin(9600);
}
void loop()
{
humiditySensorOutput = analogRead(analogIn);
int humidityPercentage = map(humiditySensorOutput, 0, 1023, 10,
70);
Serial.print("Humidity: "); // Printing out Humidity Percentage
Serial.print(humidityPercentage);
Serial.println("%");
delay(5000); // Iterate every 5 seconds
}

Output:

SY BSC IT
Introduction to Embedded System 2023 - 24

PRACTICAL 5: PROGRAM USING ULTRASONIC SENSORS

Aim:
To study the working of Ultrasonic sensors using Arduino

Components:
Arduino UNO
HC-SR04 sensor

Theory:
Ultrasonic sensors work by emitting sound waves at a frequency
too high for humans to hear. They then wait for the sound to be
reflected back, calculating the distance based on the time required.
This is similar to how radar measures the time it takes a radio wave
to return after hitting an object.

Working:
Ultrasonic sensors measure distance by sending and receiving the
ultrasonic wave. The ultrasonic sensor has a sender to emit the
ultrasonic waves and a receiver to receive the ultrasonic waves.
The transmitted ultrasonic wave travels through the air and is
reflected by hitting the Object. Arduino calculates the time taken by
the ultrasonic pulse wave to reach the receiver from the sender.
We know that the speed of sound in air is nearly 344 m/s,
So, the known parameters are time and speed (constant). Using
these parameters, we can calculate the distance traveled by the
sound wave.

SY BSC IT
Introduction to Embedded System 2023 - 24

Pin Connections:

Arduino HC-SR 04
Sensor
5V VCC
GND GND
Pin 9 TRIG
Pin 10 ECHO

Code:
// Define the pins for the ultrasonic sensor
const int trigPin = 9; // Arduino digital pin for the trigger
const int echoPin = 10; // Arduino digital pin for the echo

// Variables to store the duration and distance


long duration;
int distance;

void setup()
{
// Initialize serial communication for debugging
Serial.begin(9600);

// Define the trigger and echo pins as OUTPUT and INPUT


pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}

void loop()
{
// Trigger a pulse to the sensor
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);

SY BSC IT
Introduction to Embedded System 2023 - 24

// Measure the duration of the pulse from the echo


duration = pulseIn(echoPin, HIGH);

// Calculate the distance based on the speed of sound


distance = duration * 0.034 / 2; // Divide by 2 because the sound
travels to the object and back

// Print the distance to the serial monitor


Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm");

// Add a delay between measurements


delay(1000); // 1 second
}

Output:

SY BSC IT
Introduction to Embedded System 2023 - 24

PRACTICAL: 6 PROGRAMS USING SERVO MOTORS

Aim:
To control the motion of a Servo motor using Arduino

Components:
Arduino UNO
Servo motor

Theory:
A servo motor is an electromechanical device that produces torque
and velocity based on the supplied current and voltage. A servo
motor works as part of a closed-loop system providing torque and
velocity as
commanded from a servo controller utilizing a feedback device to
close the loop.

Working:
The servo motor has some control circuits and a potentiometer (a
variable resistor, aka pot) connected to the output shaft. In the
picture above, the pot can be seen on the right side of the circuit
board. This pot allows the control circuitry to monitor the current
angle of the servo motor.

Pin Connections:

Arduino Servo
Motor
5V Power
GND Ground
Pin A1 Signal

SY BSC IT
Introduction to Embedded System 2023 - 24

Code:
// Include the Servo library
#include <Servo.h>
Servo servoBase; // Create a Servo object and assign it a specific
name
void setup()
{
servoBase.attach(A1); // Specify the pin to use for the servo
servoBase.write(0); // Set the servo motor to the 0-degree
position
}

void loop()
{
// Sweep the servo from 0 to 180 degrees in steps of 10 degrees
for (int i = 0; i <= 180; i += 10) {
servoBase.write(i); // Set the servo to the current angle
delay(2000); // Pause for 2000 milliseconds (2 seconds)
}
}

Output:

SY BSC IT
Introduction to Embedded System 2023 - 24

PRACTICAL 7: PROGRAMS USING DIGITAL INFRARED


MOTION SENSORS

Aim:
To control the motion of a Servo motor using Arduino
Components: Arduino UNO, Servo motor

Theory:
The human body, with a surface temperature between 27°C and
36°C, emits most of its radiant energy in the wavelength range of 8
μm to 12 μm.
In the detection area, the PIR sensor’s lens receives infrared
radiation energy emitted by the human body, even through clothing.

Working:
The passive infrared sensor does not radiate energy to space. It
receives infrared radiation from the human body to make an alarm.
Any object with temperature is constantly radiating infrared rays
to the outside world. The surface temperature of the human body
is between 36° C – 27 ° C and most of its radiant energy is
concentrated in the wavelength range of 8 um-12 um.

Pin Connections:
Arduino PIR Sensor LED

5V Power
GND Ground
Pin 2 Signal
Cathode through
GND (digital)
the resistor
Pin 13 Anode

SY BSC IT
Introduction to Embedded System 2023 - 24

Code:
// C++ code //
int sensorState = 0;

void setup()
{
pinMode(2, INPUT);
pinMode(LED_BUILTIN, OUTPUT);
}

void loop()
{
//Read the state of the sensor/digital input
sensorState = digitalRead(2);
// check if sensor pin is HIGH. if it is, set the LED on.
if (sensorState == HIGH) {
digitalWrite(LED_BUILTIN, HIGH);
}
else
{
digitalWrite(LED_BUILTIN, LOW);
}
delay(10); // Delay a little bit to improve simulation performance
}

SY BSC IT
Introduction to Embedded System 2023 - 24

Output:

SY BSC IT
Introduction to Embedded System 2023 - 24

PRACTICAL 8: PROGRAM USING GAS SENSOR

Aim:
To detect smoke/fire using a Gas sensor

Components:
Arduino UNO
Gas sensor
LED
Resistor
Breadboard

Theory:
Gas sensors are devices designed to detect and measure the
concentration of gases in the surrounding environment. They are
widely used in various applications, including industrial safety,
environmental monitoring, medical diagnostics, and home
automation. Gas sensors play a crucial role in ensuring the safety
of individuals and detecting potential hazards.

Working:
The working principle of gas sensors can vary depending on the
type of sensor and the specific gas it is designed to detect.
The basic principle used in a smoke detector, whether in a real-
world device or a simulated one in TinkerCAD, is the change in
electrical conductivity or resistance in the presence of smoke
particles.

SY BSC IT
Introduction to Embedded System 2023 - 24

Pin Connections:
Arduino Gas sensor Led Resistor
B1
B2
5V
B3
GND H1 Cathode Other end
A1 Other end
A0 A2
A1 Anode

Code:
int LED = A1;
const int gas = 0;
int MQ2pin = A0;
void setup() {
Serial.begin(9600);
}
void loop() {
float sensorValue,MQ2pin;
sensorValue = analogRead(MQ2pin); // read analog input pin 0
if(sensorValue>= 470){
digitalWrite(LED,LOW);
Serial.print(sensorValue);
Serial.println(" |SMOKE DETECTED");
}
else{
digitalWrite(LED,HIGH);
Serial.println("Sensor Value: ");
Serial.println(sensorValue);
}
delay(1000);
}
float getsensorValue(int pin){
return (analogRead(pin));
}

SY BSC IT
Introduction to Embedded System 2023 - 24

Output:

SY BSC IT

You might also like