You are on page 1of 19

O.U.

R
O200045

1. PIR SENSOR WITH LED


// C++ code
//
const int pir=1;
const int led=6;
void setup()
{
pinMode(pir,INPUT);
pinMode(led,OUTPUT);
}

void loop()
{
int x=digitalRead(pir);
if(x==HIGH)
{
digitalWrite(led,HIGH);
}
else
{
digitalWrite(led,LOW);
}
}
O.U.R
O200045

2. PIR SENSOR WITH SERIAL MONITORING

// C++ code
//
const int pir=1;
void setup()
{
pinMode(pir,INPUT);
Serial.begin(9600);
}

void loop()
{
int x=digitalRead(pir);
if(x==HIGH)
{
Serial.println("Movement Detected");;
}
else
{
Serial.println("Movement Not Detected");
delay (1000);
}
}
O.U.R
O200045

3. LED USING ULTRASONIC SENSOR


const int trig=1;
const int echo=2;
const int led=12;
const int dth=200;
float duration,distance;
void setup()
{
Serial.begin(9600);
pinMode(trig,OUTPUT);
pinMode(echo,INPUT);
pinMode(led,OUTPUT);
}

void loop()
{
digitalWrite(trig, HIGH);
delayMicroseconds(10);
digitalWrite(trig, LOW);
delayMicroseconds(10);
duration=pulseIn(echo,HIGH);
distance=0.017*duration;
if(distance<dth)
digitalWrite(led,HIGH);
else
digitalWrite(led,LOW);
Serial.print(distance);
Serial.println("cm:");
}
O.U.R
O200045

4. BLINKING OF LED SOUND FOR BUZZER USING ULTRASONIC SENSOR

const int trig=1;


const int echo=2;
const int led=12;
const int dth=200;
const int buzzer=11;
float duration,distance;
void setup()
{
Serial.begin(9600);
pinMode(trig,OUTPUT);
pinMode(echo,INPUT);
pinMode(led,OUTPUT);
pinMode(buzzer,OUTPUT);
}
void loop()
{
digitalWrite(trig, HIGH);
delayMicroseconds(10);
digitalWrite(trig, LOW);
delayMicroseconds(10);
duration=pulseIn(echo,HIGH);
distance=0.017*duration;
if(distance<dth)
{
digitalWrite(led,HIGH);
digitalWrite(buzzer,HIGH);
}
else
digitalWrite(led,LOW);
digitalWrite(buzzer,LOW);
Serial.print(distance);
Serial.println("cm:");
}
O.U.R
O200045

5. LIQUID CRYSTAL DISPLAY

#include<LiquidCrystal.h>
const int rs=12,en=11,d4=6,d5=5,d6=4,d7=3;
LiquidCrystal lcd(rs,en,d4,d5,d6,d7);

void setup()
{
lcd.begin(16,2);
lcd.println("Smart";
}

void loop()
{
lcd.setCursor(0,1);
lcd.print(millis()/1000);

}
O.U.R
O200045

6. LCD USING ULTRASONIC SENSOR

#include<LiquidCrystal.h>
const int rs=12,en=11,d4=6,d5=5,d6=4,d7=3;
LiquidCrystal lcd(rs,en,d4,d5,d6,d7);
const int trig=1;
const int echo=2;
long distance,duration;
void setup()
{
lcd.begin(16,2);
pinMode(trig,OUTPUT);
pinMode(echo,INPUT);
}

void loop()
{
digitalWrite(trig,HIGH);
delayMicroseconds(20);
digitalWrite(trig,LOW);
delayMicroseconds(20);
duration=pulseIn(echo,HIGH);
distance=duration*0.017;
lcd.begin(0,1);
lcd.print(distance);
lcd.print("cm");
}
O.U.R
O200045

7. PHOTORESISTOR (LDR SENSOR)

const int led=3,ldr=A5;


void setup()
{
pinMode(led,OUTPUT);
pinMode(ldr,INPUT);
}

void loop()
{
int ldrstatus=analogRead(ldr);
if(ldrstatus<=80)
{
digitalWrite(led,HIGH);
}
else
{
digitalWrite(led,LOW);

}
}
O.U.R
O200045

8. BLINKING OF SINGLE LED

void setup()
{
pinMode(10,OUTPUT);
}
void loop()
{
digitalWrite(10,HIGH);
delay(1000);
digitalWrite(10,LOW);
delay(1000);
}

9. BLINKING OF MULTIPLE LED/

void setup()
{
pinMode(10,OUTPUT);
pinMode(9,OUTPUT);
pinMode(8,OUTPUT);
}
void loop()
{
digitalWrite(10,HIGH);
delay(1000);
digitalWrite(10,LOW);
delay(1000);
digitalWrite(9,HIGH);
delay(1000);
digitalWrite(9,LOW);
delay(1000);
digitalWrite(8,HIGH);
delay(1000);
digitalWrite(8,LOW);
delay(1000);
}
O.U.R
O200045

10. BULB BLINKING USING RELAY

int relay=1
void setup()
{
pinMode(relay,OUTPUT);
}
void loop()
{
digitalWrite(relay,HIGH);
delay(1000);
digitalWrite(relay,LOW);
delay(1000);
}
O.U.R
O200045

11. 3 WAY Traffic Light Controller


void setup()
{
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
}
void loop()
{
digitalWrite(6,LOW);
digitalWrite(11,LOW);
digitalWrite(5, HIGH);
digitalWrite(10,HIGH);
digitalWrite(13,HIGH);
delay(3000); // Wait for 1000 millisecond(s)
digitalWrite(10, LOW);
digitalWrite(9,HIGH);
delay(1000);
digitalWrite(8,HIGH);
digitalWrite(5,LOW);
digitalWrite(9,LOW);
digitalWrite(7,HIGH);
delay(3000);
digitalWrite(13,LOW);
digitalWrite(12,HIGH);
delay(1000);
digitalWrite(11,HIGH);
digitalWrite(12,LOW);
digitalWrite(8,LOW);

digitalWrite(10,HIGH);
delay(3000);
digitalWrite(7,LOW);
digitalWrite(6,HIGH);
delay(1000);
}
O.U.R
O200045

12. RGB

// Define the pins for the RGB LED


const int redPin = 9; // Pin for the red color
const int greenPin = 10; // Pin for the green color
const int bluePin = 11; // Pin for the blue color

void setup() {
// Set the RGB LED pins as OUTPUT
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
}

void loop() {
// Turn on the red LED, wait for a second, then turn it off
digitalWrite(redPin, HIGH);
delay(1000);
digitalWrite(redPin, LOW);

// Turn on the green LED, wait for a second, then turn it off
digitalWrite(greenPin, HIGH);
delay(1000);
digitalWrite(greenPin, LOW);

// Turn on the blue LED, wait for a second, then turn it off
digitalWrite(bluePin, HIGH);
delay(1000);
digitalWrite(bluePin, LOW);
}
O.U.R
O200045

THEORY

The Internet of Things (IoT) refers to the interconnected network of physical devices, vehicles,
appliances, and other objects embedded with sensors, software, and connectivity, enabling
them to collect and exchange data over the internet. Essentially, IoT transforms everyday
objects into intelligent, data-generating entities that can communicate with each other and
with central systems.
These devices, equipped with sensors and actuators, can gather real-time information from their
surroundings and interact with their environment or other connected devices. The data generated by
IoT devices can range from simple temperature readings and location information to more complex
data like health metrics or industrial process parameters.
IoT has diverse applications across various industries, including healthcare, agriculture, smart cities,
manufacturing, and home automation. It has the potential to enhance efficiency, improve decision-
making, and create new business models. By facilitating seamless communication between devices
and enabling the analysis of vast amounts of data, IoT plays a pivotal role in shaping the future of
technology and contributing to the development of smarter, more interconnected systems. However,
it also raises important considerations regarding security, privacy, and the responsible management
of the vast amounts of data generated by these interconnected devices.

Layers of IOT:

The architecture of the Internet of Things (IoT) involves a multi-layered framework designed to
enable the seamless integration and communication between various components. While specific
implementations may vary, a typical IoT architecture consists of the following layers:
1. Perception Layer:
• At the bottom layer, devices and sensors are responsible for perceiving and collecting
data from the physical world. These can include sensors for temperature, humidity,
motion, and more.
• Devices in this layer often have limited processing capabilities and may use
protocols like MQTT or CoAP to transmit data.
2. Network Layer:
• This layer involves the transmission of data from the perception layer to the next
layer, typically using communication protocols like Wi-Fi, Bluetooth, Zigbee, or
cellular networks.
• Gateways may be used to aggregate data from multiple devices and establish a
connection to the cloud or the next layer.
3. Middleware Layer:
O.U.R
O200045

• The middleware layer manages the communication and integration of data between
the devices and the application layer. It often includes protocols, data processing, and
message queuing systems.
• Middleware helps handle issues such as data format translation, security, and device
management.
4. Application Layer:
• This layer is where the processed data is utilized to derive meaningful insights and
make informed decisions. It involves application development, data storage,
analytics, and user interfaces.
• Cloud platforms are commonly used in this layer to provide scalable storage and
processing capabilities.
5. Business Layer:
• At the top layer, organizations leverage the insights gained from IoT data to make
strategic decisions, optimize processes, and create new business models.
• Integration with existing enterprise systems and applications occurs in this layer.
6. Security and Privacy Layer:
• Security is a crucial consideration in IoT. This layer involves implementing measures
to secure data, devices, and communication to prevent unauthorized access and
protect user privacy.
• Security protocols, encryption, and access control mechanisms are implemented at
this layer.

Advantages of IoT:
1. Efficiency and Automation: IoT enables automation of various processes, leading to
increased efficiency in industries, homes, and cities. Automated systems can respond to real-
time data, optimizing resource usage.
2. Data Collection and Insights: IoT devices continuously collect and transmit data,
providing valuable insights for decision-making. This data-driven approach enhances
operational efficiency and supports informed strategies.
3. Improved Quality of Life: In healthcare, smart homes, and wearable devices, IoT
contributes to improved quality of life by monitoring health, enhancing safety, and providing
personalized experiences.
4. Cost Savings: IoT applications help reduce operational costs by optimizing resource usage,
predicting maintenance needs, and improving energy efficiency. This is particularly
beneficial in industrial settings.
5. Innovation and New Business Models: IoT fosters innovation by enabling the
development of new products and services. It opens opportunities for creating innovative
business models and revenue streams.
O.U.R
O200045

6. Remote Monitoring and Control: IoT allows remote monitoring and control of devices
and systems, leading to better management of assets, increased safety, and the ability to
respond promptly to issues.
7. Environmental Impact: Through efficient resource management, IoT can contribute to
sustainability efforts by minimizing waste, reducing energy consumption, and optimizing
transportation systems.
Disadvantages of IoT:
1. Security Concerns: IoT devices are susceptible to security breaches, posing risks such as
unauthorized access, data manipulation, and privacy violations. The large attack surface
makes securing IoT ecosystems challenging.
2. Privacy Issues: The vast amount of data collected by IoT devices raises concerns about user
privacy. Unauthorized access to personal information can lead to identity theft and misuse of
sensitive data.
3. Interoperability Challenges: Many IoT devices are developed by different manufacturers
using diverse communication protocols. Lack of standardization can result in
interoperability issues, hindering seamless integration.
4. Complexity and Integration Challenges: Building and maintaining IoT systems can be
complex due to the diverse technologies involved. Integration with existing infrastructure
and legacy systems can be challenging.
5. Reliability and Connectivity: Reliability issues may arise due to network outages or device
malfunctions. Ensuring consistent connectivity and minimizing downtime are ongoing
challenges in IoT deployments.
6. Cost of Implementation: Initial setup costs for IoT infrastructure and devices can be high,
particularly for small businesses or individuals. This cost can include hardware, software,
and ongoing maintenance expenses.
7. Ethical Concerns: As IoT becomes more pervasive, ethical concerns regarding surveillance,
data ownership, and the potential misuse of technology need careful consideration and
regulation.

PIR SENSOR

A commonly used sensor to detect the motion of an object is the Passive Infrared (PIR) sensor. PIR
sensors are designed to detect changes in infrared radiation within their field of view. These sensors
are often used in motion-activated lighting systems, security systems, and other applications where
the detection of human or animal motion is essential.
Here's how a PIR sensor works:
1. Infrared Detection: PIR sensors can detect infrared radiation emitted by objects. All objects
with a temperature above absolute zero emit heat in the form of infrared radiation.
O.U.R
O200045

2. Detection of Changes: PIR sensors consist of a pyroelectric sensor, which generates a


voltage when exposed to infrared radiation. The sensor is divided into multiple segments,
and each segment produces a signal based on the infrared radiation it detects.
3. Differential Sensing: The sensor compares the signals from different segments. When an
object, such as a person or animal, moves within the sensor's field of view, it causes a
change in the distribution of infrared radiation across the segments.
4. Output Signal: The PIR sensor outputs a signal when it detects a significant change in the
infrared radiation pattern. This signal is used to trigger an action, such as turning on a light
or activating an alarm.

An ultrasonic sensor is a device that uses ultrasonic waves to measure the distance between the
sensor and an object. These sensors are commonly used for distance measurement, object detection,
and navigation in various applications, including robotics, industrial automation, and automotive
systems.
Here's how an ultrasonic sensor typically works:
1. Ultrasonic Waves Generation: The sensor emits ultrasonic waves, which are sound waves
with frequencies higher than the upper audible limit of human hearing (typically above 20
kHz). In ultrasonic sensors, frequencies in the range of 40 kHz to 400 kHz are commonly
used.
2. Wave Propagation: The ultrasonic waves travel through the air until they encounter an
object in their path.
3. Reflection: When the ultrasonic waves hit an object, they are reflected back towards the
sensor.
4. Time Measurement: The sensor measures the time taken for the ultrasonic waves to travel
to the object and back. Using the speed of sound in air, the sensor calculates the distance to
the object.
5. Distance Calculation: The distance (D) is calculated using the formula: D=21
×speed of sound×round-trip time
6. Output: The calculated distance is then provided as an output by the sensor. This
information can be used by a microcontroller or other control systems for decision-making
or automation.
Advantages of Ultrasonic Sensors:
• Non-contact: Ultrasonic sensors do not physically touch the object, making them suitable for
applications where contact is not desired.
• Versatility: They can be used to detect a wide range of materials and objects, regardless of
color or transparency.
• Relatively low cost: Ultrasonic sensors are often cost-effective compared to some other
distance-measuring technologies.
O.U.R
O200045

Limitations:
• Limited accuracy in some conditions: Factors like temperature, humidity, and air pressure
can affect the speed of sound, impacting the accuracy of distance measurements.
• Beam width: Ultrasonic sensors typically have a cone-shaped beam pattern, which can affect
the accuracy of measurements for small or irregularly shaped objects.
• Limited in extreme environments: Ultrasonic sensors may face challenges in environments
with high levels of dust, fog, or acoustic interference.
A relay is an electromagnetic switch that is commonly used to control high-power devices with a
low-power signal. It is an essential component in electrical and electronic systems, providing a way
to control circuits with different voltage levels or power requirements. Relays are widely used in
applications such as automation, home appliances, industrial control systems, and automotive
electronics.
Here's how a relay generally works:
1. Electromagnetic Coil: A relay consists of an electromagnetic coil and a set of contacts. The
coil is wound around a core and is typically made of copper wire.
2. Input Signal: When a low-power signal, often from a microcontroller or a low-voltage
circuit, is applied to the coil, it generates an electromagnetic field.
3. Attracting the Armature: The electromagnetic field attracts an armature (a movable iron
core or lever) connected to the coil. This movement is usually mechanically linked to the
contacts.
4. Contact Closure: As the armature moves, it causes a change in the state of the relay
contacts. There are different types of relay contacts, including normally open (NO) and
normally closed (NC). In the resting state, the relay may have one set of contacts closed
(either NO or NC), and when the coil is energized, the contacts switch to the opposite state.
5. Switching High-Power Circuit: The switched contacts of the relay are used to control a
separate, higher-power circuit. This allows a low-power control signal to manage the
operation of devices that require more power.
Relays come in various types, including electromagnetic relays, solid-state relays, and reed relays.
Each type has its own advantages and is suitable for different applications.
• Electromagnetic Relays: Use an electromagnetic coil to mechanically open and close
contacts.
• Solid-State Relays (SSR): Use semiconductor devices like transistors and have no moving
parts, providing faster switching and longer life.
• Reed Relays: Use a small coil to control a set of contacts sealed in a glass envelope,
offering fast response times and high reliability.
Relays play a crucial role in electrical systems by providing a reliable and efficient way to control
high-power circuits with low-power signals, isolating control circuits from high-voltage or high-
current loads
O.U.R
O200045

LCD

LCD stands for Liquid Crystal Display, and it is a flat-panel display technology commonly used in
devices such as computer monitors, television screens, smartphones, and other electronic devices.
LCDs have become widespread due to their compactness, energy efficiency, and ability to provide
sharp and vibrant images.
Here's a brief overview of how LCDs work:
1. Liquid Crystals: LCDs utilize liquid crystals, a unique state of matter that has properties of
both liquids and solids. In their natural state, these crystals allow light to pass through.
2. Pixel Structure: The display is made up of a matrix of pixels, each containing red, green,
and blue sub-pixels. These sub-pixels combine to produce a full range of colors.
3. Backlight: Unlike some display technologies (like OLED), LCDs require a separate light
source to illuminate the screen. This source is typically a fluorescent or LED backlight
positioned behind the liquid crystal layer.
4. Polarization: The LCD panel includes two layers of glass with a liquid crystal solution
sandwiched in between. Each layer has a polarizing filter. When no electrical current is
applied, the liquid crystals align themselves in a way that prevents light from passing
through the layers.
5. Applying Voltage: When an electric current is applied to a specific pixel, the liquid crystals
untwist, allowing light to pass through the layers. The color and intensity of the light passing
through are determined by the combination of the red, green, and blue sub-pixels.
6. Color and Brightness Control: The varying voltages applied to each pixel control the
intensity of each sub-pixel, thus controlling the color and brightness of the overall pixel.
Advantages of LCDs:
• Energy Efficiency: LCDs generally consume less power compared to older display
technologies like CRT (cathode ray tube) monitors.
• Compact and Thin: LCDs are thin and lightweight, making them suitable for slim and
portable devices.
• Sharp Image Quality: LCDs can provide high-resolution and sharp image quality, making
them suitable for applications where visual clarity is important.
Disadvantages of LCDs:
• Limited Viewing Angles: LCDs may experience a degradation in image quality when
viewed from extreme angles.
• Backlight Dependency: The need for a backlight can result in less deep blacks compared to
technologies like OLED.
• Response Time: Some LCDs may have slower response times compared to other display
technologies, impacting their suitability for fast-motion content.
O.U.R
O200045

The Arduino Uno is a popular open-source microcontroller board that serves as a foundation for
many electronics projects. Developed by the Arduino company, it is part of the larger Arduino
ecosystem, which includes various models of boards, shields (add-on boards), and a user-friendly
integrated development environment (IDE). The Arduino Uno is widely used by hobbyists,
students, and professionals for prototyping and developing a variety of electronic projects.
Key features and components of the Arduino Uno include:
1. Microcontroller: The heart of the Arduino Uno is the ATmega328P microcontroller. This 8-
bit microcontroller operates at a clock speed of 16 MHz and has 32KB of flash memory for
program storage, 2KB of SRAM, and 1KB of EEPROM.
2. Digital and Analog I/O Pins: The board has a total of 14 digital I/O pins, where 6 can be
used as PWM (Pulse Width Modulation) outputs, and 6 are analog input pins. These pins
allow for interfacing with various sensors, actuators, and other electronic components.
3. USB Interface: The Arduino Uno features a USB interface, making it easy to connect to a
computer for programming and power. It can be powered through the USB connection or an
external power supply.
4. Power Supply: The board can be powered using a USB cable, an external power supply, or
by connecting a battery to the onboard power jack. It operates at 5V DC.
5. Reset Button: The Arduino Uno includes a reset button, which can be used to restart the
microcontroller and rerun the uploaded program.
6. LEDs: There are built-in LEDs on the board, including a power indicator, a pin 13 LED that
is often used for basic testing, and TX/RX LEDs indicating data transmission/reception over
USB.
7. Voltage Regulator: The onboard voltage regulator ensures a stable 5V power supply for the
microcontroller and connected components.
8. Clock Crystal: The board uses a 16 MHz crystal oscillator for accurate timing and
synchronization.
The Arduino Uno is known for its simplicity and ease of use, making it an ideal choice for
beginners and those new to electronics and programming. Its open-source nature encourages a large
community of users to share code, libraries, and knowledge. Users can write programs for the
Arduino Uno using the Arduino IDE, which simplifies the process of writing, uploading, and
debugging code for the board. The availability of a wide range of shields and modules further
extends the functionality of the Arduino Uno for diverse projects.

Photoresistor:

A photoresistor, also known as a light-dependent resistor (LDR) or photocell, is a type of resistor


whose resistance varies with the amount of light falling on it. It belongs to the class of
O.U.R
O200045

optoelectronic devices, and its resistance decreases as the light intensity increases. Conversely, the
resistance increases as the light intensity decreases.
Key characteristics and working principles of photoresistors:
1. Material: Photoresistors are typically made from semiconductor materials such as cadmium
sulfide (CdS) or cadmium selenide (CdSe). These materials exhibit a change in electrical
conductivity in response to variations in incident light.
2. Resistance Variation: When exposed to light, the semiconductor material within the
photoresistor absorbs photons, promoting electrons to a higher energy state and decreasing
the resistance of the material. The greater the light intensity, the more photons are absorbed,
resulting in a lower resistance.
3. Dark Resistance: In the absence of light, photoresistors have a higher resistance, known as
dark resistance. This value can vary based on the specific material and design of the
photoresistor.
4. Applications: Photoresistors are widely used in applications where automatic control based
on light conditions is required. Common applications include ambient light sensing in
streetlights, camera exposure control, and automatic switching of outdoor lighting.
5. Voltage Divider Configuration: In electronic circuits, photoresistors are often used in a
voltage divider configuration. The varying resistance of the photoresistor changes the
voltage at the junction between the photoresistor and a fixed resistor. This voltage can be
read by a microcontroller or other circuitry to determine the ambient light level.
6. Speed of Response: Photoresistors typically have a relatively slow response time compared
to other light sensors. They are well-suited for applications where rapid changes in light
intensity are not critical.
7. Spectral Sensitivity: The spectral sensitivity of a photoresistor depends on the material
used. Different materials respond to different parts of the electromagnetic spectrum, so the
choice of material is important for specific applications.
Despite their simplicity and ease of use, photoresistors may not be suitable for applications
requiring precise and rapid light measurements. For such cases, other light sensors like photodiodes
or phototransistors may be more appropriate. However, for basic light-sensing applications where a
simple and cost-effective solution is needed, photoresistors remain a popular choice.

You might also like