Course Content
📘 MODULE 11 – Edge Avoiding Robot
📦 MODULE 12 – Smart Multi-Function Robot (Mega Project)
Arduino Hands-On Programming and Robotics Course

📖 Lesson 3.2 – LDR Module Circuit & Analog Reading

🎯 Learning Objectives

After completing this lesson, students will be able to:

✅ Connect an LDR Module with Arduino UNO

✅ Identify AO and DO pins

✅ Read Analog Output using Arduino

✅ Use analogRead() function

✅ Display light intensity values in Serial Monitor

✅ Test sensor response under different lighting conditions


1. Introduction

In the previous lesson, we learned about the LDR Sensor Module and its four pins:

  • VCC
  • GND
  • AO
  • DO

In this lesson, we will connect the LDR Module to Arduino UNO and read the light intensity using the Analog Output (AO) pin.

This is an important step because Arduino must first understand how much light is present before it can control any automatic lighting system.


2. Project Overview

In this lesson:

LDR Module

Measures Light

Arduino Reads AO Pin

Displays Values

Serial Monitor Shows Light Intensity


3. Components Required

Component Quantity
Arduino UNO 1
LDR Sensor Module 1
USB Cable 1
Jumper Wires 4
Computer/Laptop 1

4. Understanding the Connection

We will use:

 
AO (Analog Output)
 

because we want actual light intensity values.

The AO pin produces continuously changing voltage levels.

Arduino converts these voltages into values between:

 
0 to 1023
 

using its ADC.


5. Circuit Connections

LDR Module Pin Arduino UNO
VCC 5V
GND GND
AO A0
DO Not Connected

Connection Diagram

 
LDR Module          Arduino UNO

VCC -----------> 5V

GND -----------> GND

AO -----------> A0

DO -----------> Not Used
 

6. Why Are We Using AO?

AO provides:

 
0 – 1023
 

light intensity values.

Example:

Light Condition Reading
Bright Light 800–1023
Room Light 400–700
Dim Light 150–350
Dark Room 0–150

These values allow us to make intelligent decisions later.


7. Understanding Analog Reading

Arduino UNO has:

10-Bit ADC

This means:

 
0V = 0
 

and

 
5V = 1023
 

The LDR Module outputs voltages according to the amount of light detected.

Arduino converts those voltages into numbers.


8. Arduino Program

 
int ldrValue;

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  ldrValue = analogRead(A0);

  Serial.println(ldrValue);

  delay(500);
}

9. Code Explanation

Variable Declaration

 
int ldrValue;
 

Stores the sensor value.


Start Serial Communication

 
Serial.begin(9600);
 

Allows Arduino to send data to Serial Monitor.


Read Sensor Value

 
ldrValue = analogRead(A0);
 

Reads the analog voltage from AO pin.


Display Value

 
Serial.println(ldrValue);
 

Shows the reading on Serial Monitor.


Delay

 
delay(500);
 

Waits 500 milliseconds before the next reading.


10. Uploading the Program

Step 1

Connect Arduino UNO to Computer.


Step 2

Open Arduino IDE.


Step 3

Select:

 
Tools → Board → Arduino UNO
 

Step 4

Select Correct COM Port.


Step 5

Upload the Program.


Step 6

Open Serial Monitor.


Step 7

Set Baud Rate:

 
9600
 

11. Observing the Readings

When the Serial Monitor opens:

You will see values such as:

 
650
648
655
660
 

These values represent light intensity.


12. Testing with Different Light Sources

Test 1 – Room Light

Point sensor toward normal room lighting.

Example Reading:

 
500
600
650
 

Test 2 – Mobile Flashlight

Shine flashlight on sensor.

Example Reading:

 
850
900
950
 

Test 3 – Cover Sensor

Cover the LDR using your finger.

Example Reading:

 
50
80
120
 

13. Understanding the Results

Bright Light

Reading becomes higher.


Darkness

Reading becomes lower.


Changing Light

Reading continuously changes.

This proves that the sensor is working correctly.


14. Creating a Light Intensity Table

Students should record readings.

Condition Reading
Sunlight ______
Room Light ______
Flashlight ______
Dark Room ______
Covered Sensor ______

This helps understand sensor behavior.


15. Why Calibration is Important

Every room has different lighting conditions.

Example:

One room may show:

 
400
 

Another room may show:

 
650
 

for normal light.

Therefore we must determine suitable threshold values before automation.


16. Real-World Applications

The same analog readings are used in:

Automatic Street Lights

Smart Home Lighting

Solar Tracking Systems

Smart Agriculture

Light Intensity Monitoring

Security Systems


17. Common Beginner Mistakes

Mistake 1

Connecting AO to a digital pin.

Wrong:

 
AO → D2
 

Correct:

 
AO → A0
 

Mistake 2

Using:

 
digitalRead(A0);
 

Wrong.

Use:

 
analogRead(A0);
 

Mistake 3

Wrong baud rate.

Program:

 
Serial.begin(9600);
 

Serial Monitor must also be:

 
9600
 

Mistake 4

Using loose jumper wires.

Can cause unstable readings.


18. Troubleshooting

No Readings

Check:

  • USB Connection
  • COM Port
  • Upload Success

Constant Value

Check:

  • AO Connection
  • Sensor Exposure to Light

Random Values

Check:

  • Loose Wiring
  • Poor Power Supply

Serial Monitor Blank

Check:

 
Serial.begin(9600);
 

and Serial Monitor baud rate.


📊 Summary

In this lesson, we learned:

✅ LDR Module Wiring

✅ AO Pin Connection

✅ Analog Reading

✅ Serial Monitor Output

✅ Light Intensity Measurement

✅ Sensor Testing

The AO pin allows Arduino to measure actual light intensity values, which will be used in the next lesson to automatically control an LED based on light conditions.


📖 Key Terms

AO

Analog Output

ADC

Analog to Digital Converter

Analog Reading

Numerical value from 0–1023

Serial Monitor

Tool used to display sensor readings

Calibration

Adjusting sensor values for proper operation


🎯 Quiz

1. Which pin provides analog values?

A. VCC

B. GND

C. AO ✅

D. DO


2. Which Arduino pin is used in this lesson?

A. D2

B. D13

C. A0 ✅

D. D8


3. Which function reads analog values?

A. digitalRead()

B. analogRead() ✅

C. digitalWrite()

D. Serial.read()


4. What is the analog range of Arduino UNO?

A. 0–255

B. 0–512

C. 0–1023 ✅

D. 0–4096


5. Which tool displays sensor readings?

A. Plotter

B. Serial Monitor ✅

C. Task Manager

D. Device Manager


🏠 Assignment

Task 1

Connect the LDR module and display values in Serial Monitor.

Task 2

Record readings under five different lighting conditions.

Task 3

Create a table showing light intensity values.

Task 4

Explain why AO must be connected to an analog pin.

Task 5

Identify the highest and lowest reading observed during testing.

Scroll to Top