Hema Es
Hema Es
233
Practical No. 1
Aim : Blinking of LEDs
Theory: 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 :
Roll No. 233
Pin connections :
Arduino LED
GND
Cathode through Resistor
A1 Anode
Practical No. 2
Aim : Program Using Light Sensitive Sensors.
Components: Arduino UNO, LED, Photodiode and 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.
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.
This closed-loop system ensures that the LED’s brightness is always synchronized with
The surrounding light levels.
Roll No. 233
Circuit Diagram :
Pin Connections :
sv Right pin
A0 Left pin
Pin 9 Anode
Code :
Practical No. 3
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.
The TMP36 temperature sensor is a precision analog sensor. It generates an output
voltage
That is linearly proportional to the Celsius temperature. 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.
The demonstration showcases the practical application of the TMP36 temperature
sensor in Conjunction with an Arduino board for real-time temperature monitoring. It
highlights how to Interface the sensor, read its analog output, and display the
temperature information. This Knowledge can be applied to various temperature-
sensing applications, including weather
Stations, environmental monitoring, and more.
Diagram :
Roll No. 233
Pin Connection :
sv Left pin
A1 Center Pin
Code :
OutPut :
Roll No. 233
Practical No. 4
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.
Roll No. 233
Diagram :
Pin Connection :
Arduino Potentiometer
5V Left Pin
A1 Center Pin
Code :
Serial.print("Humidity: ");
Serial.print(humidityPercentage);
Serial.println("%");
delay(5000);
}
Roll No. 233
Output :
Roll No. 233
Practical No. 5
Aim : Program Using Ultrasonic Sensors.
Components: Arduino UNO, HC-SR04 sensor
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:
a. Ultrasonic Emission: The sensor emits a high-frequency sound wave, usually in
The ultrasonic range (around 40 kHz). This sound wave is inaudible to humans.
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.
d. Calculating Distance: By measuring the time it takes for the sound wave to travel
To the object and back (i.e., the time it takes for the echo to return), the HC-SR04
Can calculate the distance to the object using the speed of sound in the air
(approximately 343 meters per second or 1125 feet per second at room
Temperature).
e. Output: The sensor provides the calculated distance as an output in the form of a
Digital pulse or duration in microseconds that can be easily converted to distance
In centimeters or inches.
This distance measuring technique is non-contact, making it suitable for a wide range of
Applications, including obstacle avoidance in robots, measuring liquid levels, and more. The HC-
SR04 sensor is popular among hobbyists and electronics enthusiasts due to its
Affordability,ease of use, and compatibility with microcontrollers like Arduino and Raspberry Pi.
It typically has four pins: VCC (power supply), GND (ground), Trig (trigger), and Echo (echo
Signal output).
Roll No. 233
Diagram :
PIn Connection :
5v Vcc
GND GND
Pin 9 TRIG
Pin 10 ECHO
Code :
}
void loop(){ digitalWrite(trigPin,LOW);
delayMicroseconds(2);
digitalWrite(trigPin,HIGH);
delayMicroseconds(10);
digitalWrite(trigPin,LOW); duration=
pulseIn(echoPin,HIGH); distance=
duration*0.034/2; Serial.print("distance: ");
Serial.print(distance); Serial.println(" cm");
delay(1000);
}
Output :
Roll No. 233
Roll No. 233
Practical No. 6
Aim : Program Using Servo Motors.
Components: Arduino UNO, Servo motor
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.
A micro servo motor functions as follows:
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.
Potentiometer (Feedback Device): Most servo motors have a potentiometer (a variable resistor)
Connected to the output shaft. This potentiometer provides feedback to the control circuitry
About the current position of the motor.
When we connect a micro servo motor to an Arduino, we typically use a library (such as the
Servo library in Arduino) to control its movements.
The working of Servo motor interfaced with Arduino can be understood as follows
The movement of a servo motor attached to an Arduino is controlled by sending a series of
Pulses to the servo motor. These pulses are typically generated using a technique called Pulse
Width Modulation (PWM).
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
Roll No. 233
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.
Diagram :
Pin Connection :
5V Power
GND Ground
PIN A1 Signal
Code :
#include<Servo.h> Servo
servoBase; void setup(){
servoBase.attach(A1);
Roll No. 233
servoBase.write(0);
}
void loop(){
for(int i = 0; i<= 180; i+= 10){ servoBase.write(i);
delay(2000);
}
}
OUTPUT—
Roll No. 233
Practical No. 7
Aim : To detect motion of any object using infrared sensors.
Components: Arduino UNO, Passive Infrared (PIR) Sensor, LED and resistor (1 KΩ)
Theory:
A Passive Infrared (PIR) sensor is a type of electronic sensor that detects infrared (IR) radiation
Emitted by objects in its field of view. PIR sensors are often used to detect motion and are
Commonly found in security systems, lighting control, and other applications where the presence
Of people or animals needs to be detected.
Here’s how a basic PIR sensor works:
1. Detection of Infrared Radiation: PIR sensors are equipped with a special material that is
Sensitive to infrared radiation. When an object with a temperature above absolute zero (-
273.15°C or -459.67°F) moves in the sensor’s field of view, it emits infrared radiation.
2. Pyroelectric Material: The sensor contains a pyroelectric material, typically a crystal that
Generates a voltage when exposed to changes in temperature. The pyroelectric material is
Divided into segments, and each segment is connected to a pair of electrodes.
3. Detection of Changes in Infrared Radiation: As an object moves within the sensor’s detection
Range, the amount of infrared radiation reaching different segments of the pyroelectric material
Changes. This results in variations in the voltage generated by the material.
4. Signal Processing: The sensor’s electronics process these voltage changes and convert them
Into a signal that indicates motion or the presence of a heat source.
5. Output Signal: The sensor typically provides a digital output signal that can be used to trigger
An alarm, turn on lights, or perform other actions based on the detected motion.
One of the key advantages of PIR sensors is their low cost, simplicity, and efficiency in motion
Detection applications. However, it’s essential to note that PIR sensors can be sensitive to
Changes in temperature and may produce false alarms in certain situations, such as when there
Are sudden temperature changes in the environment. Advanced PIR sensor designs and signal
Processing techniques are employed to minimize false positives and enhance overall
Performance.
Roll No. 233
Diagram :
Pin Connection :
5V Power
GND Ground
Pin 2 Signal
Pin 13 Anode
Roll No. 233
Code :
int sensorState = 0;
void setup()
{
pinMode(2,INPUT);
pinMode(LED_BUILTIN,OUTPUT);
}
void loop()
{
sensorState = digitalRead(2); if(sensorState ==
HIGH){ digitalWrite(LED_BUILTIN,HIGH);
}else {
digitalWrite(LED_BUILTIN,LOW);
}
delay(10000);
}
OUTPUT—
Roll No. 233
Practical No. 8
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:
1. Gas Sensing Element:
- In a real smoke detector, a specialized gas sensing element is used. This element often
Consists of a material that interacts with smoke particles in the air.
2. Change in Conductivity or Resistance:
- When smoke particles are present, they interfere with the normal operation of the gas
Sensing element. This interference leads to a change in the electrical conductivity or resistance
Of the sensing element.
3. Voltage Divider Circuit:
- The gas sensor is typically part of a voltage divider circuit. In the case of a simulated circuit
In TinkerCAD, a variable resistor is often used to represent the gas sensor.
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 significantly, suggesting the
Presence of smoke.
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.
Roll No. 233
Diagram :
Pin Connection :
B1
5v B2
B3
A0 A2
A1 Anode
Code :
void loop() {
int sensorValue = analogRead(SENSOR_PIN);
Output :