Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

CIE – 2

Practical Section (50 Marks)

1. Write steps and code To connect an Arduino with a servo motor for
automatic door opening using a PIR (Passive Infrared) ? (10 Marks)

Answer:-
To connect an Arduino with a servo motor for automatic door opening using a
PIR (Passive Infrared) sensor, follow these steps:

1. Hardware Setup:
- Connect the PIR sensor to the Arduino.
- PIR Sensor VCC pin → Arduino 5V pin
- PIR Sensor GND pin → Arduino GND pin
- PIR Sensor OUT pin → Arduino digital pin (e.g., Pin 2)
- Connect the servo motor to the Arduino.
- Servo Motor VCC pin → Arduino 5V pin
- Servo Motor GND pin → Arduino GND pin
- Servo Motor Signal pin → Arduino digital pin (e.g., Pin 9)

2. Write Arduino Code:


#include <Servo.h>

#define PIR_PIN 2
#define SERVO_PIN 9

Servo doorServo;

void setup() {
pinMode(PIR_PIN, INPUT);
doorServo.attach(SERVO_PIN);
doorServo.write(0); // Close the door initially
Serial.begin(9600);
}

void loop() {
int motionDetected = digitalRead(PIR_PIN);
if (motionDetected == HIGH) {
Serial.println("Motion detected!");
openDoor();
delay(10000); // Keep the door open for 10 seconds
closeDoor();
}
}

void openDoor() {
doorServo.write(90); // Open the door
delay(1000); // Delay to allow door to open fully
}

void closeDoor() {
doorServo.write(0); // Close the door
delay(1000); // Delay to allow door to close fully
}

3. Explanation:
- The PIR sensor detects motion and sends a signal to the Arduino when
motion is detected.
- When motion is detected, the Arduino triggers the servo motor to open the
door by rotating it to a specific angle (e.g., 90 degrees).
- After a delay (e.g., 10 seconds), the Arduino rotates the servo motor back to
its initial position, closing the door.
- Adjust the servo motor angle and delay times according to your specific
requirements.
- Make sure to include the Servo library in your Arduino sketch.

4. Testing:
- Upload the code to your Arduino board and observe the behavior.
- Test the setup by moving in front of the PIR sensor. The servo motor should
open the door when motion is detected and close it after a set delay.

2. Connect an Arduino with an LDR (Light Dependent Resistor) sensor


for automatic light control in response to darkness? (10 Marks)

Answer:-
To connect an Arduino with an LDR (Light Dependent Resistor) sensor for
automatic light control in response to darkness, follow these steps:
1. Hardware Setup:
- Connect the LDR sensor to the Arduino.
- LDR Sensor one leg (variable resistor) → Arduino analog pin (e.g., A0)
- LDR Sensor other leg (fixed resistor) → Arduino 5V pin
- LDR Sensor fixed resistor leg → Arduino GND pin

2. Write Arduino Code:


const int LDR_PIN = A0; // LDR sensor connected to analog pin A0
const int LED_PIN = 13; // LED connected to digital pin 13

void setup() {
pinMode(LED_PIN, OUTPUT);
Serial.begin(9600);
}

void loop() {
int lightValue = analogRead(LDR_PIN); // Read LDR sensor value
Serial.print("Light Intensity: ");
Serial.println(lightValue);

if (lightValue < 500) { // Adjust threshold value as needed


digitalWrite(LED_PIN, HIGH); // Turn on LED in darkness
} else {
digitalWrite(LED_PIN, LOW); // Turn off LED in light
}

delay(1000); // Adjust delay as needed


}

3. Explanation:
- The LDR sensor acts as a variable resistor, and its resistance changes based
on the intensity of light falling on it.
- In darkness, the resistance of the LDR increases, resulting in a lower analog
voltage read by the Arduino.
- The Arduino continuously reads the analog voltage from the LDR sensor
using the `analogRead()` function.
- If the light intensity falls below a certain threshold (e.g., 500), indicating
darkness, the Arduino turns on the LED connected to pin 13 using
`digitalWrite()`.
- If the light intensity is above the threshold, indicating light, the Arduino
turns off the LED.
- Adjust the threshold value and delay time according to your specific
requirements.

4. Testing:
- Upload the code to your Arduino board and observe the behavior.
- Test the setup by covering the LDR sensor with your hand or placing it in a
dark environment. The LED should turn on in darkness and turn off in light.

3. Connect an Arduino with an IR (Infrared) sensor and a buzzer for an


intrusion alarm system? (10 Marks)

Answer:-
To connect an Arduino with an IR (Infrared) sensor and a buzzer for an
intrusion alarm system, follow these steps:

1. Hardware Setup:
- Connect the IR sensor to the Arduino.
- IR Sensor VCC pin → Arduino 5V pin
- IR Sensor GND pin → Arduino GND pin
- IR Sensor OUT pin → Arduino digital pin (e.g., Pin 2)
- Connect the buzzer to the Arduino.
- Buzzer positive (+) pin → Arduino digital pin (e.g., Pin 3)
- Buzzer negative (-) pin → Arduino GND pin

2. Write Arduino Code:


#define IR_PIN 2 // IR sensor connected to digital pin 2
#define BUZZER_PIN 3 // Buzzer connected to digital pin 3

void setup() {
pinMode(IR_PIN, INPUT);
pinMode(BUZZER_PIN, OUTPUT);
Serial.begin(9600);
}

void loop() {
int intruderDetected = digitalRead(IR_PIN);
if (intruderDetected == HIGH) {
Serial.println("Intrusion detected!");
activateAlarm();
delay(5000); // Alarm duration (5 seconds)
}
}

void activateAlarm() {
tone(BUZZER_PIN, 1000); // Turn on the buzzer at 1000Hz frequency
delay(1000); // Buzzer on duration (1 second)
noTone(BUZZER_PIN); // Turn off the buzzer
}

3. Explanation:
- The IR sensor detects any intrusion and sends a signal to the Arduino when
it detects an object within its sensing range.
- When an intrusion is detected (IR sensor output is HIGH), the Arduino
triggers the buzzer to sound the alarm.
- The `tone()` function generates a square wave of the specified frequency (in
Hertz) on the specified pin (BUZZER_PIN). This creates an audible sound
through the buzzer.
- After a delay (e.g., 5 seconds), the buzzer is turned off using the `noTone()`
function.

4. Testing:
- Upload the code to your Arduino board and observe the behavior.
- Test the setup by placing an object within the sensing range of the IR sensor.
The buzzer should sound the alarm when an intrusion is detected.

4. Connect arduino with wifi module for mobile app controlled light on
and off? (20 Marks)

Answer:-
To connect an Arduino with a WiFi module for mobile app-controlled light on
and off functionality, you can use a WiFi module like ESP8266 or ESP32 along
with the Blynk platform for IoT projects. Blynk allows you to create a mobile
app interface to control your Arduino devices remotely over the internet. Here's
how you can set it up:

1. Hardware Setup:
- Connect the WiFi module (ESP8266 or ESP32) to the Arduino.
- Ensure the correct wiring between the Arduino and the WiFi module based
on the specific module you're using. Typically, connections include TX, RX,
VCC, GND, and sometimes a CH_PD or EN pin.
- Connect an LED and a current-limiting resistor to one of the Arduino's
digital pins to simulate the light.

2. Install Blynk App:


- Download and install the Blynk app from the App Store (iOS) or Google
Play Store (Android) on your smartphone.

3. Set up Blynk Project:


- Open the Blynk app and create a new project.
- Choose the appropriate hardware (e.g., Arduino Uno) and connection type
(WiFi).
- Blynk will send an authentication token to your email. Note this token down
as you'll need it in your Arduino code.

4. Write Arduino Code:


- Install the Blynk library in your Arduino IDE.
- Write the following code and replace `<YourAuthToken>` with the
authentication token from your email:

#define BLYNK_PRINT Serial


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = "YourAuthToken"; // Auth token from Blynk


char ssid[] = "YourWiFiSSID"; // Your WiFi SSID
char pass[] = "YourWiFiPassword"; // Your WiFi password

void setup() {
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
}

void loop() {
Blynk.run();
}

BLYNK_WRITE(V0) { // Virtual pin V0


int pinValue = param.asInt();
if (pinValue == 1) {
// Turn on the LED
digitalWrite(LED_BUILTIN, HIGH);
} else {
// Turn off the LED
digitalWrite(LED_BUILTIN, LOW);
}
}

5. Configure Blynk App:


- Add a Button widget in the Blynk app and set it to control Virtual Pin V0.

6. Testing:
- Upload the code to your Arduino board.
- Power up your Arduino and ensure it's connected to the same WiFi network
as your smartphone.
- Open the Blynk app and press the button to control the LED. The LED
should turn on and off based on the button's state in the app.

Theoretical Section (30 Marks)

1. Question 1 (10 Marks): Introduction to Home Automation


- Define home automation and discuss its significance in modern living.
- Explain how home automation enhances convenience, energy efficiency, and
security.

2. Question 2 (10 Marks): Arduino and its Applications


- Describe Arduino and its key features.
- Discuss various applications of Arduino in the field of home automation.

3. Question 3 (10 Marks): Components and Sensors used in Home Automation


- List and describe the components commonly used in home automation projects.
- Explain the functioning and applications of sensors like PIR motion sensors,
temperature sensors, and humidity sensors in home automation systems.
Theoretical Section (30 Marks)

1. Question 1 (10 Marks): Introduction to Home Automation


Answer:-

- Definition: Home automation refers to the use of technology to control and


automate household appliances and systems remotely or autonomously. It involves
integrating various devices and systems within a home to provide convenience,
energy efficiency, comfort, and security to its occupants.

- Significance:
- Convenience: Home automation allows users to control appliances and
systems such as lighting, heating, cooling, security cameras, and entertainment
systems remotely through smartphones, tablets, or voice commands.
- Energy Efficiency: Automated systems can optimize energy usage by
regulating lighting, heating, and cooling based on occupancy and environmental
conditions, thereby reducing energy wastage and utility bills.
- Security: Home automation systems can include features like surveillance
cameras, motion sensors, and smart door locks, enhancing home security by
providing real-time monitoring and alerts for unauthorized access.
- Comfort: Automation of tasks such as adjusting room temperature, opening
and closing blinds, and controlling audio/video systems enhances the comfort and
convenience of occupants.
- Accessibility: Home automation can benefit elderly or disabled individuals by
providing assistive technologies that enable them to control devices and appliances
more easily.

2. Question 2 (10 Marks): Arduino and its Applications


Answer:-

- Arduino Overview: Arduino is an open-source electronics platform based on


easy-to-use hardware and software. It consists of a microcontroller board (e.g.,
Arduino Uno, Arduino Nano) and a development environment (Arduino IDE) for
programming the board. Arduino boards are equipped with digital and analog
input/output pins that can be interfaced with various sensors, actuators, and other
electronic components.

- Key Features of Arduino:


- Easy to use and learn: Arduino provides a simple programming environment
suitable for beginners and experienced developers alike.
- Open-source: Arduino hardware designs and software libraries are freely
available, encouraging collaboration and innovation within the community.
- Extensible: Arduino boards can be extended with shields (plug-in boards) for
additional functionalities such as wireless communication, motor control, and
display interfaces.
- Versatile: Arduino supports a wide range of sensors, actuators, and
communication protocols, making it suitable for diverse applications.

- Applications of Arduino in Home Automation:


- Lighting control: Arduino can be used to automate lighting systems based on
occupancy, ambient light levels, or scheduled timers.
- Climate control: Arduino-based systems can regulate heating, cooling, and
ventilation to maintain comfortable indoor environments.
- Security systems: Arduino can interface with sensors such as motion detectors,
door/window sensors, and surveillance cameras to implement home security
solutions.
- Energy monitoring: Arduino-based energy monitoring systems can track
electricity usage, identify energy-intensive appliances, and optimize energy
consumption patterns.
- Irrigation systems: Arduino-controlled irrigation systems can automate
watering schedules based on soil moisture levels, weather forecasts, and plant
requirements.

3. Question 3 (10 Marks): Components and Sensors used in Home Automation


Answer:-

- Components in Home Automation:


- Microcontrollers: Microcontrollers like Arduino form the backbone of home
automation systems, providing the processing power and I/O capabilities needed to
control devices and sensors.
- Actuators: Actuators such as relays, servo motors, and stepper motors are used
to control physical devices like lights, motors, locks, and valves in response to
input from sensors or commands from users.
- Sensors: Sensors play a crucial role in home automation by detecting various
environmental parameters such as temperature, humidity, motion, light, and sound.
Common sensors used in home automation include PIR motion sensors,
temperature sensors (e.g., DHT11, DS18B20), humidity sensors, light sensors
(LDR), gas sensors, and proximity sensors.
- Communication Modules: Communication modules such as Wi-Fi, Bluetooth,
Zigbee, and RF transceivers enable connectivity between home automation devices
and external control interfaces such as smartphones, tablets, or central control
hubs.
- Display Interfaces: Display interfaces like LCD displays, OLED displays, and
LED matrices provide feedback and status information to users about the operation
of home automation systems.

- Applications of Sensors:
- PIR Motion Sensors: Used for detecting human presence and triggering
actions such as turning on lights or activating security alarms.
- Temperature Sensors: Monitor room temperature for climate control and
energy management purposes.
- Humidity Sensors: Measure humidity levels to prevent mold growth, optimize
HVAC systems, and maintain indoor comfort.
- Light Sensors (LDR): Adjust lighting levels based on ambient light conditions
to save energy and enhance user comfort.
- Gas Sensors: Detect gases like carbon monoxide (CO) and propane for early
warning of potential hazards such as gas leaks.
- Proximity Sensors: Detect the presence or absence of objects or individuals to
automate tasks like opening/closing doors, activating appliances, or adjusting room
settings.

You might also like