Practical 7

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

FromToNote
LDR module VCCArduino 5V-
LDR module GNDArduino GND-
LDR module AOArduino A0-
Bar graph segments 1-6Arduino 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

  1. The Arduino averages 10 ADC samples of the LDR channel.
  2. The average is converted to an approximate lux value with a calibration factor.
  3. The bar graph displays 0-6 segments according to the lux level.
  4. Below 50 lux the red DARK LED lights; above 500 lux the green BRIGHT LED lights.
  5. 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 System
2const 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;
7
8const int DARK_ADC = 60; // Measured ADC value in darkness
9const int BRIGHT_ADC = 950; // Measured ADC value in full light
10
11const int DARK_LUX = 50; // Thresholds for the zone LEDs
12const int BRIGHT_LUX = 500;
13
14int 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}
22
23void setBar(int active) {
24 for (int i = 0; i < SEGMENTS; i++) {
25 digitalWrite(BAR_PINS[i], i < active ? HIGH : LOW);
26 }
27}
28
29void 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}
35
36void loop() {
37 int adc = readLightADC();
38 long lux = map(adc, DARK_ADC, BRIGHT_ADC, 1, 1000);
39 lux = constrain(lux, 1, 1000);
40
41 int level = lux / 170; // 0..6 segments
42 if (level > SEGMENTS) level = SEGMENTS;
43 setBar(level);
44
45 digitalWrite(BRIGHT_LED, lux > BRIGHT_LUX ? HIGH : LOW);
46 digitalWrite(DARK_LED, lux < DARK_LUX ? HIGH : LOW);
47
48 Serial.print("ADC: ");
49 Serial.print(adc);
50 Serial.print(" ~Lux: ");
51 Serial.println(lux);
52 delay(300);
53}