Dynamic Light Control System Report
Dynamic Light Control System Report
Submitted by:
Group No.: 1
Group Members:
1. Adarsh T U BT24ECI021
Task Number # 4
1 Introduction 3-4
2 Objective 5
5 Code 10-11
6 References 12
Chapter 1: Introduction
This project implements a smart lighting solution using an ESP32 microcontroller, ultrasonic
sensor, I2C-based 16x2 LCD, and a PWM-controlled LED. The system automatically adjusts
the brightness of an LED based on the distance of an object or person from the sensor.
As an object approaches the sensor, the LED becomes brighter. As it moves away, the brightness
gradually decreases. The distance and brightness percentage are displayed in real-time on the
LCD. This project mimics the functionality of energy-efficient lighting systems and provides a
Chapter 2: Objective
2. Map the measured distance to a brightness level for an LED using PWM.
- Interactive displays
The ESP32 serves as the core processing unit. It reads the sensor data, controls the LED
brightness using PWM, and communicates with the LCD over I2C.
This sensor is used to measure the distance between itself and an approaching object by
it requires only two data pins: SDA and SCL, simplifying wiring.
An LED is used to visually represent the brightness level based on distance. PWM from the
I2C LCD:
- VCC -> 5V
LED:
Chapter 5: Code
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
pwmChannel = 0;
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
ledcSetup(pwmChannel, freq,
resolution); ledcAttachPin(ledPin,
pwmChannel);
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Initializing...
"); delay(1000);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW); long duration
constrain(brightness, 0, 255);
ledcWrite(pwmChannel, brightness);
Chapter 6: References
[1] https://randomnerdtutorials.com/esp32-pwm-arduino-ide/
[2] https://lastminuteengineers.com/hc-sr04-ultrasonic-arduino-tutorial/
[3] https://randomnerdtutorials.com/esp32-i2c-lcd-arduino-ide/
[4] https://www.espressif.com/
[5] https://www.robotique.tech