Embedded Systems Practical file (1) (1)
Embedded Systems Practical file (1) (1)
SYIT
Embedded Systems Practical File
SYIT EMBEDDED SYSTEMS PRACTICAL FILE
Sr Page Faculty
Date Practical Remarks
No No Sign
1 Introduction to Arduino 1
Practical 1: Introduction to
Arduino
Aim:
1. To study the basics of Arduino circuits and bread-boarding
2. Blinking of LEDs
Theory:
1
SYIT EMBEDDED SYSTEMS PRACTICAL FILE
2. Input/output Pins: Arduino boards have a set of digital and analog pins that
can be used to read data (inputs) or send data (outputs). Digital pins work with
binary signals (0 or 1), while analog pins can read a range of values. The number
and types of pins vary among different Arduino board models.
3. Power Supply: Arduino boards can be powered via USB, an external power
supply, or a battery. Some boards have built-in voltage regulators, which make
them compatible with a range of power sources.
4. USB Port: Arduino boards often feature a USB port for programming and power
supply. This allows you to connect the board to your computer and upload code.
5. Reset Button: A reset button is provided to restart the Arduino, allowing you to
upload new code or reset the program.
6. LED Indicator: Many Arduino boards include a built-in LED (Light Emitting Diode)
on pin 13, which can be used for testing and basic visual feedback.
Arduino Software:
The Arduino platform comes with its integrated development environment (IDE).
The Arduino IDE is a software tool that allows you to write, compile, and upload
code to the Arduino board. Key features of the IDE include:
- Code Library: Arduino has a vast library of pre-written code and functions
that simplify common tasks, making it accessible to beginners.
- Serial Monitor: The IDE includes a serial monitor that allows you to
communicate with the Arduino board and view debugging information.
- Community Support: The Arduino community is large and active, offering forums,
tutorials, and extensive documentation to help users troubleshoot issues and learn.
2
SYIT EMBEDDED SYSTEMS PRACTICAL FILE
Components Used:
1. Arduino UNO
2. Breadboard
3. LED
4. Resistor (330 Ω)
The Following is the Circuit diagram we need to implement using the TinkerCAD
simulation environment,
Arduino UNO is used to blink the LED continuously, we connect the pin 13 to the
anode of the LED and cathode of the LED is connected to a resistor (330 Ω) ro limit
the current passing through the LED. If 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.
Circuit Diagram:
3
SYIT EMBEDDED SYSTEMS PRACTICAL FILE
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)
}
For the Video Demonstration of the given practical click on the link below
or scan the QR-Code
https://youtu.be/cCFZGNqm9EY
4
SYIT EMBEDDED SYSTEMS PRACTICAL FILE
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.
Components:
a) Photodiode: A photodiode is a light-sensitive semiconductor device that
generates a current or voltage proportional to the incident light's intensity.
It acts as the input sensor in this system.
b) LED: An LED (Light Emitting Diode) is used as the output device. It emits
light and can be controlled to vary its brightness.
c) Arduino: The Arduino microcontroller is the brain of the project. It reads
data from the photodiode, processes it, and controls the LED's brightness
accordingly.
Working:
a) Photodiode Operation:
The photodiode is connected to one of the Arduino's analog input pins.
When exposed to light, the photodiode generates a current or voltage that is
directly proportional to the light intensity.
Arduino reads the analog voltage from the photodiode using one of its analog
pins.
b) Control Algorithm:
The Arduino is programmed with an algorithm that translates the analog
reading from the photodiode into a control signal for the LED.
The algorithm typically involves mapping the photodiode's output to the
LED's brightness. For example, when the photodiode detects more light, the
LED becomes brighter, and vice versa.
c) Feedback Loop:
The system operates in a feedback loop. As light conditions change, the
photodiode detects the variations and sends this information to the Arduino.
The Arduino processes the data and adjusts the LED's brightness in real-time
based on the input from the photodiode.
5
SYIT EMBEDDED SYSTEMS PRACTICAL FILE
Circuit Diagram:
Pin Connections:
Arduino Photoresistor LED
5V Right pin
GND Left pin through
(Power) a Series
Resistor
A0 Left pin
Pin 9 Anode
GND Cathode through
(Digital) a Series Resistor
For the Video Demonstration of the given practical click on the link below
or scan the QR-Code
https://youtu.be/Oz0p9CI61bY
7
SYIT EMBEDDED SYSTEMS PRACTICAL FILE
Theory:
The TMP36 is a low-cost analog temperature sensor that can be easily integrated
with Arduino boards. It provides an analog voltage output that varies linearly with
temperature. This practical aims to show how to measure and display real-time
temperature data using a TMP36 temperature sensor and an Arduino. The
temperature data will be displayed through suitable method.
Circuit Diagram:
8
SYIT EMBEDDED SYSTEMS PRACTICAL FILE
Pin Connections:
Arduino TMP36
Sensor
5V Left pin
GND Right pin
A1 Center pin
Code:
intlightSensorValue = 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
intledBrightness = 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
}
For the Video Demonstration of the given practical click on the link below
or scan the QR-Code
https://youtu.be/rB3QKd-DJNg
9
SYIT EMBEDDED SYSTEMS PRACTICAL FILE
Theory:
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.
TinkerCAD:
TinkerCAD is a web-based platform for simulating and designing electronic circuits
and Arduino- based projects.
It's an excellent tool for testing and prototyping virtually, even when physical
components are unavailable.
Demo Overview:
In this demo, we learn how to connect a potentiometer to an Arduino board in the
TinkerCAD environment.
We understand the wiring and connections required to read variable resistance values
from the potentiometer accurately.
Programming:
We see how to write the code to read and convert the analog voltage from the
potentiometer into digital values and the humidity.
Practical Applications:
While the potentiometer doesn't directly measure humidity, we observe how
variable sensor inputs are used in applications like volume control, dimmer
switches, and other scenarios where adjustable values are required.
The demo provides hands-on experience in interfacing a potentiometer with an
Arduino, which can be a valuable skill for various electronic projects.
10
SYIT EMBEDDED SYSTEMS PRACTICAL FILE
Understanding how to read analog values and convert them into digital format is a
fundamental aspect of working with sensors and input devices.
The demo serves as a practical example of using a potentiometer in an Arduino project
and its potential applications in real-world scenarios.
While the potentiometer isn't a humidity sensor, this demonstration can still be
educational and relevant, regarding interfacing variable sensors with Arduino.
Circuit Diagram:
Pin Connections:
Arduino Potentiometer
5V Left pin
GND Right pin
A1 Center pin
11
SYIT EMBEDDED SYSTEMS PRACTICAL FILE
Code:
/*
This code records the humidity using a simulated potentiometer.
The Humidity is simulated by mapping the potentiometer output into
percentages.
*/
void setup() {
Serial.begin(9600);
}
void loop() {
humiditySensorOutput = analogRead(analogIn);
inthumidityPercentage = map(humiditySensorOutput, 0, 1023, 10, 70);
For the Video Demonstration of the given practical click on the link below
or scan the QR-Code
https://youtu.be/CFL5rtbQ95A
12
SYIT EMBEDDED SYSTEMS PRACTICAL FILE
Theory:
The HC-SR04 is an inexpensive and widely used ultrasonic distance sensor module.
It is often employed in various projects and applications, such as robotics,
automation, and DIY electronics. The name "HC-SR04" is derived from the model or
product code of this specific sensor module.
The HC-SR04 sensor utilizes ultrasonic sound waves to determine the distance
between the sensor and an object. Here's how it works:
b. Sound Wave Reflection: The emitted sound wave travels through the
air until it encounters an object. When it hits the object, it bounces
back towards the sensor.
c. Receiving the Echo: The sensor has a built-in receiver to detect the
reflected sound wave, also known as an echo.
13
SYIT EMBEDDED SYSTEMS PRACTICAL FILE
supply), GND (ground), Trig (trigger), and Echo (echo signal output).
14
SYIT EMBEDDED SYSTEMS PRACTICAL FILE
Circuit Diagram:
Pin Connections:
HC-SR 04
Arduino
Sensor
5V VCC
GND GND
Pin 9 TRIG
Pin 10 ECHO
Code:
void setup() {
// Initialize serial communication for debugging
Serial.begin(9600);
15
SYIT EMBEDDED SYSTEMS PRACTICAL FILE
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);
For the Video Demonstration of the given practical click on the link below
or scan the QR-Code
https://youtu.be/0VZrqKZsUQE
16
SYIT EMBEDDED SYSTEMS PRACTICAL FILE
Theory:
A micro servo motor is a small-sized servo motor designed for applications where
space is limited. Servo motors, in general, are devices that incorporate a feedback
mechanism to control the speed and position of the motor accurately. They are
commonly used in robotics, remote- controlled vehicles, and various other projects
where precise control of movement is required.
Motor: The motor inside the servo is responsible for producing the mechanical
motion. It typically consists of a DC motor.
Gear Train: Servos have a gear train that converts the high-speed, low-torque
output of the motor into low-speed, high-torque motion.
Control Circuitry: The control circuitry is responsible for interpreting the signals
received from an external source (like an Arduino) and translating them into precise
movements.
The working of Servo motor interfaced with Arduino can be understood as follows
17
SYIT EMBEDDED SYSTEMS PRACTICAL FILE
a. Pulse Width Modulation (PWM): Arduino boards have digital pins that
can output PWM signals. PWM is a technique where the duration of a
pulse is varied while the frequency remains constant. In the case of
servo motors, the pulse width is crucial because it determines the
position to which the servo motor should move.
b. Servo Library: Arduino provides a Servo library that simplifies the
task of controlling servo motors. This library abstracts the details of
generating PWM signals, making it easier to control the servo.
c. Attach Function: In the Arduino code, you first use the `attach`
function to associate a servo object with a specific pin on the
Arduino to which the signal wire of the servo is connected.
d. Write Function: To move the servo to a specific position, you use
the `write` function. The argument passed to this function is the
desired angle. The angle corresponds to the position to which the
servo should move. For example,
`myservo.write(90);` would move the servo to the 90-degree position.
e. Pulse Generation: Internally, the Servo library translates the angle
specified in the `write` function into an appropriate pulse width. The
library generates the necessary PWM signal, and the Arduino outputs
this signal through the specified digital pin.
f. Control Loop: The servo motor's control circuitry interprets the PWM
signal and adjusts the position of the motor accordingly. The
feedback mechanism (potentiometer) inside the servo constantly
provides information about the motor's current position to ensure
that it reaches and maintains the desired position.
g. Looping or Sequential Control: In a loop or sequence of commands,
you can vary the angles sent to the servo to make it move
continuously or in a specific pattern.
Circuit Diagram:
18
SYIT EMBEDDED SYSTEMS PRACTICAL FILE
Pin Connections:
Servo
Arduino
Motor
5V Power
GND Ground
Pin A1 Signal
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)
}
}
For the Video Demonstration of the given practical click on the link below
or scan the QR-Code
https://youtu.be/0VZrqKZsUQE
19
SYIT EMBEDDED SYSTEMS PRACTICAL FILE
Theory:
A PIR sensor, or Passive Infrared sensor, is a type of electronic sensor that detects
infrared (IR) radiation emitted by objects in its field of view. Unlike active infrared
sensors that emit infrared light and measure the reflection, PIR sensors passively
receive infrared radiation. They are commonly used for motion detection in various
applications, including security systems, lighting control, and automation.
The theoretical working of a PIR sensor involves the principles of detecting infrared
radiation emitted by objects, particularly those that generate heat, the steps are as
follows
Pyroelectric Effect:
- The pyroelectric material exhibits the pyroelectric effect, meaning it
generates a voltage when its temperature changes. This effect is due to the
reorganization of charge asymmetry within the crystal lattice of the material.
- The rapid temperature change caused by an object entering the sensor's field
of view leads to the generation of an electric charge within the pyroelectric
material.
Signal Processing:
- The generated electric charge is then processed by the sensor's electronics. The
electronics amplify and convert this charge into a usable voltage signal.
- The voltage signal is further processed to determine the presence of motion or
changes in the infrared radiation.
Threshold Detection:
- PIR sensors typically have a built-in threshold or sensitivity setting. The
processed signal is compared to this threshold.
- If the signal surpasses the threshold, it is interpreted as a significant
20
SYIT EMBEDDED SYSTEMS PRACTICAL FILE
21
SYIT EMBEDDED SYSTEMS PRACTICAL FILE
Output Signal:
- When motion is detected, the PIR sensor produces an output signal. This signal
can be in the form of a digital signal (HIGH or LOW) that is sent to a
microcontroller, such as an Arduino.
- The microcontroller can then trigger specific actions, such as turning on lights,
sounding an alarm, or sending a notification.
Field of View:
- PIR sensors have a specific field of view and range. Objects within this field of
view that emit infrared radiation can be detected, while those outside the field of
view may not trigger the sensor.
It's important to note that PIR sensors are particularly sensitive to the heat emitted by
living organisms, making them useful for motion detection applications. They are
commonly used in security systems, automatic lighting, and other applications where
detecting human or animal motion is essential.
Circuit Diagram:
Pin Connections:
22
SYIT EMBEDDED SYSTEMS PRACTICAL FILE
Code:
// C++ code
//
intsensorState = 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
}
For the Video Demonstration of the given practical click on the link below
or scan the QR-Code
https://youtu.be/8V0GRwtpJ1I
23
SYIT EMBEDDED SYSTEMS PRACTICAL FILE
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.
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.
The principle can be understood through the following steps:
4. Arduino Interface:
- The output of the voltage divider circuit is connected to an analog pin on an
Arduino. The Arduino reads the analog value, which corresponds to the resistance or
conductivity of the gas sensor.
5. Threshold Detection:
- A threshold value is set in the Arduino code. If the analog value exceeds this
threshold, it indicates that the resistance of the gas sensor has changed
24
SYIT EMBEDDED SYSTEMS PRACTICAL FILE
25
SYIT EMBEDDED SYSTEMS PRACTICAL FILE
6. Alarm Activation:
- When the threshold is surpassed, the Arduino activates an alarm signal. In the
Tinkercad simulation, this is often represented by turning on an LED.
Circuit Diagram:
26
SYIT EMBEDDED SYSTEMS PRACTICAL FILE
Code:
int LED = A1;
constint gas =
0; int MQ2pin =
A0;
void setup() {
Serial.begin(960
0);
}
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(sensorValu
e);
}
delay(1000);
}
floatgetsensorValue(int
pin){ return
(analogRead(pin));
}
For the Video Demonstration of the given practical click on the link below
or scan the QR-Code
https://youtu.be/2G9GYcBoRQI
27