Light Intensity Monitoring and Display System
Ambient light level on a bar graph display
Aim
To measure the intensity of surrounding light with an LDR and display it as a numeric value plus a multi-level LED bar graph that indicates bright, normal, and dark conditions.
Overview
The LDR module converts light intensity to an analog voltage. The Arduino samples the value, converts it to an approximate lux reading using a calibration constant, and lights a 6-segment LED bar graph proportionally. A green LED marks the Bright zone and a red LED marks the Dark zone so light conditions are readable at a glance even without the numeric display.
Components Required
- Arduino Uno
- LDR / photoresistor sensor module (AO output)
- LED bar graph (6 segments) + 220 ohm resistors
- Green LED (bright indicator)
- Red LED (dark indicator)
- Breadboard and jumper wires
Circuit Connections
| From | To | Note |
|---|---|---|
| LDR module VCC | Arduino 5V | - |
| LDR module GND | Arduino GND | - |
| LDR module AO | Arduino A0 | - |
| Bar graph segments 1-6 | Arduino D2-D8 | - |
| Green LED (via 220R) | Arduino D10 | - |
| Red LED (via 220R) | Arduino D11 | - |
Interactive Circuit Diagram
Simulate the circuit: adjust the sensor inputs below and watch the outputs react according to the control logic.
Loading Wokwi components...
Working
- The Arduino averages 10 ADC samples of the LDR channel.
- The average is converted to an approximate lux value with a calibration factor.
- The bar graph displays 0-6 segments according to the lux level.
- Below 50 lux the red DARK LED lights; above 500 lux the green BRIGHT LED lights.
- Readings are printed on the serial monitor for verification.
Control Logic
lux = map(adc, DARK_ADC, BRIGHT_ADC, 1, 1000) with calibration at two known light levels. Bar level = clamp(lux / 170, 0, 6). Thresholds (50/500 lux) split the range into Dark, Normal and Bright zones.
Arduino Code
1// Practical 7: Light Intensity Monitoring and Display System2const int LDR_PIN = A0;3const int BRIGHT_LED = 10;4const int DARK_LED = 11;5const int BAR_PINS[] = { 2, 3, 4, 5, 6, 7 };6const int SEGMENTS = 6;78const int DARK_ADC = 60; // Measured ADC value in darkness9const int BRIGHT_ADC = 950; // Measured ADC value in full light1011const int DARK_LUX = 50; // Thresholds for the zone LEDs12const int BRIGHT_LUX = 500;1314int readLightADC() {15 long sum = 0;16 for (int i = 0; i < 10; i++) {17 sum += analogRead(LDR_PIN);18 delay(2);19 }20 return sum / 10;21}2223void setBar(int active) {24 for (int i = 0; i < SEGMENTS; i++) {25 digitalWrite(BAR_PINS[i], i < active ? HIGH : LOW);26 }27}2829void setup() {30 pinMode(BRIGHT_LED, OUTPUT);31 pinMode(DARK_LED, OUTPUT);32 for (int i = 0; i < SEGMENTS; i++) pinMode(BAR_PINS[i], OUTPUT);33 Serial.begin(9600);34}3536void loop() {37 int adc = readLightADC();38 long lux = map(adc, DARK_ADC, BRIGHT_ADC, 1, 1000);39 lux = constrain(lux, 1, 1000);4041 int level = lux / 170; // 0..6 segments42 if (level > SEGMENTS) level = SEGMENTS;43 setBar(level);4445 digitalWrite(BRIGHT_LED, lux > BRIGHT_LUX ? HIGH : LOW);46 digitalWrite(DARK_LED, lux < DARK_LUX ? HIGH : LOW);4748 Serial.print("ADC: ");49 Serial.print(adc);50 Serial.print(" ~Lux: ");51 Serial.println(lux);52 delay(300);53}