Parts shop on Daraz
⚡
Circuits · Repair · DIY projects by SR Jewel

LDR Sensor with Arduino: Testing Light-Dependent Resistance

Sr Jewel September 01, 2025 Arduino

What Is an LDR?

A light-dependent resistor (LDR)


A light-dependent resistor (LDR), also called a photoresistor, changes resistance with the light falling on it. Its resistance generally decreases in brighter light and increases in darkness.

Build a Simple Arduino Test

An Arduino reads voltage at an analog input, so use the LDR with a fixed resistor as a voltage divider. One common 5 V arrangement is:

  1. Connect one LDR leg to the board’s 5 V supply.
  2. Connect the other LDR leg to analog pin A0.
  3. Connect a 10 kΩ resistor between A0 and GND.

Use a supply voltage that is safe for your board’s analog input. With this divider orientation, the analog reading typically increases as the light gets brighter. Other divider arrangements can reverse that behavior.

Read the Sensor Values

Upload this sketch, open the Serial Monitor at 9600 baud, and compare the reading with the sensor uncovered and then shaded:

const int ldrPin = A0;

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

void loop() {
  int reading = analogRead(ldrPin);
  Serial.println(reading);
  delay(250);
}

The reading is a relative measurement, not a calibrated lux value. LDRs vary, and a fixed resistor that works in dim conditions may limit the useful range in bright light. Adjust the divider resistor if the readings quickly reach the top or bottom of your board’s range.

Further Reading

See Adafruit’s photocell guide for more detail on voltage-divider wiring and choosing a resistor.

Safety first. Electrical and electronic work can be dangerous. Follow proper procedures, use the right tools and protective equipment, and leave high-voltage or hazardous work to qualified or properly supervised people.
SR

SR JEWEL · Electronic Help Care

Electronics technician and content creator from Jessore, Bangladesh. I build and repair circuits, amplifiers, LED displays and musical instrument electronics, and publish the diagrams and fixes that work in practice.

Comments

Electronic Help Care

ElectronicHelpCare.com is a practical electronics and technology resource for students, hobbyists, technicians, and DIY enthusiasts. Discover electronics repair guides, circuit diagrams, PCB design, Arduino, ESP32, IoT projects, LED displays, power supplies, solar systems, troubleshooting tips, component information, and step-by-step tutorials. Our goal is to make electronics learning, repair, and innovation easier through useful, practical, and easy-to-understand technical content.

About

Electronic Help Care shares practical electronics tutorials, circuit diagrams, PCB layouts, Arduino projects and repair guides.
;}}

Search this blog

Recent Posts

Tags

Comments

Octapad & MIDI Projects

Featured Posts

Video Tutorials

Recent DIY Projects

More Electronics Tutorials

DIY Electronics

Audio Amplifier Circuits

Arduino Projects

Repair Guides

Featured

Breaking News