Final Year Project
Automatic Fan and
Light using Arduino
Date: 4th June, 2025
Submitted By:
Group 08: BSE Section C
Abrar ul haq __________________ SP25-BSE-006
Rana Majahid Arshaf ____________ SP25-BSE-114
Mubashir Nazar ________________ SP25-BSE-006
Subaina Zainab ________________ SP25-BSE-120
Manishma Fatima_______________ SP25-BSE-063
Areeb Fatima __________________SP25-BSE-024
Submitted To:
Course __________________ Lab Applied Lab
Instructor___________________ Dr. Naima Amin
1
Introduction
In the modern era of smart automation and sustainable living, it has become
essential to design systems that can adapt dynamically to environmental
conditions. Manual control of fans and lights leads to unnecessary energy
consumption and discomfort. This project aims to solve that problem by
introducing an intelligent, microcontroller-based system that automatically adjusts
the speed of a fan and the brightness of a light source according to ambient
temperature and light intensity, respectively.
The system uses sensors (LM35 and LDR) to collect environmental data,
processes it using an Arduino Uno R3, and actuates the devices using transistors
and PWM (Pulse Width Modulation). A 16x2 LCD with I2C interface displays the
real-time status of temperature, light intensity, fan speed, and light brightness in
percentage.
Project Objectives
The main objectives of this project are:
● To design and implement an automatic environmental control system
using sensors and actuators.
● To control the fan speed based on temperature using PWM signals.
● To control the light intensity based on ambient light using an LDR.
● To display sensor data and device status on an LCD screen in real-time.
● To apply concepts of embedded systems, electronics, and physics to solve
a real-world problem.
2
Component List
Component Quantit Description
y
Arduino Uno R3 (SMD) 1 Microcontroller board for data processing
LM35 Temperature Sensor 1 Analog sensor that outputs 10mV/°C
LDR 1 Light sensor whose resistance varies with
light
10kΩ Resistor 1 Used with LDR to form a voltage divider
2N2222 NPN Transistor 2 Acts as electronic switch for fan and LED
220Ω Resistors 2 Base resistor for transistors
1N4007 Diodes 2 Flyback protection for fan and LED
16x2 LCD with I2C Module 1 Displays temperature, light, fan %, LED %
DC Fan 1 Controlled by PWM to vary speed
LED Bulb 1 Light source controlled by PWM
9V Battery 2 Power source for Arduino and output
devices
Breadboard + Wires – For prototyping the circuit
3
System Diagram
4
Working Principle
1 Temperature-Based Fan Control
● The LM35 sensor outputs analog voltage linearly proportional to
temperature.
● Arduino reads the voltage at analog pin A0 and converts it to °C.
● If temperature exceeds a threshold (25°C), Arduino starts sending a PWM
signal to pin D9.
● This PWM controls the base of a 2N2222 transistor through a 220Ω
resistor.
● The transistor switches the fan connected between +9V and the collector of
2N2222.
● The emitter is grounded, allowing the fan to run based on duty cycle of
PWM (speed).
2 Light-Based LED Brightness Control
● The LDR sensor is used in a voltage divider with a 10kΩ resistor.
● The voltage at the midpoint is connected to analog pin A1.
● Arduino reads this voltage and maps it inversely to a PWM signal (dark =
brighter light).
● The PWM is sent to pin D10, which controls a second 2N2222 transistor
switching the LED.
5
● As room brightness decreases, LED brightness increases automatically.
3 LCD Output
● A 16x2 LCD with I2C module is used for status display.
● Connected to Arduino pins A4 (SDA) and A5 (SCL).
● LCD alternates every 3 seconds:
○ First screen: Temperature (°C) and light level (0–1023)
○ Second screen: Fan speed % and LED brightness %
Circuit Explanation
● 2N2222 Transistor: Acts as an electronic switch.
○ Base → PWM pin (through 220Ω resistor)
○ Collector → Negative terminal of fan/LED
○ Emitter → Common GND
● 1N4007 Diodes across fan and LED provide flyback protection.
● Power can be supplied via:
○ One 9V adapter for all components, OR
6
○ Separate power supplies (e.g., one for Arduino, one for fan/light) —
only if GND is shared.
Code Logic (Overview)
1. Read analog value from A0 (temperature).
2. Convert it to Celsius and map it to PWM (0–255).
3. Read analog value from A1 (light).
4. Invert and map it to PWM for LED.
5. Apply PWM signals to:
○ D9 → Fan (via 2N2222)
○ D10 → LED (via 2N2222)
6. Display values on LCD:
○ Rotate between environmental data and device output every 3
seconds.
7
Physics Principles Used
Principle Application
Electricity Fundamental to powering all devices and
sensors
Magnetism (indirect) DC fan operation uses electromagnetic
principles
Analog to Digital Conversion Arduino reads LM35/LDR as analog voltages
Pulse Width Modulation Used to control motor speed and LED
(PWM) brightness
Transistor Switching 2N2222 used as a controllable switch
Voltage Divider Used with LDR to provide a variable voltage
signal
Observed Results
Condition Fan Speed LED Brightness
Hot and Dark High High
Cold and Bright Off Low
Hot and Bright High Low
Cold and Dark Off High
8
Advantages
● Smart, real-time response to environmental changes
● Low power and cost-efficient
● Expandable to real-world applications
● Uses simple, widely available components
Limitations
● 9V battery may not provide sufficient current for fan
● Accuracy limited by sensor resolution (10-bit ADC)
● No memory or logging unless upgraded
● Fan speed is approximate; no actual RPM feedback
Applications
● Smart homes and energy-saving rooms
● Classroom/laboratory automation
● Agriculture (e.g., greenhouse temperature control)
● IoT-based environment monitoring projects
9
Precautions
● Always connect GNDs together (Arduino, fan, LED)
● Do not exceed 12V input to Arduino Vin
● Do not draw motor power from Arduino 5V pin
● Check 2N2222 transistor pinout before wiring
● Use diodes across motors/LEDs to avoid back EMF
Future Scope and Enhancements
● Add DHT11/DHT22 for humidity sensing
● Add Hall sensor to measure real fan RPM (magnetic sensing)
● Add RTC module for time-based control
● Connect to Wi-Fi using ESP8266 for remote access (IoT)
● Add manual override switch/button
Conclusion
This project successfully demonstrates an effective and low-cost method to automatically control
fan speed and light intensity based on environmental conditions. It integrates sensors, PWM
control, transistor switching, and real-time feedback using an LCD. This project combines multiple
electronics and physics principles in a hands-on way, making it ideal for learning and real-world
applications.
10