Same-day dispatch before 2 PM · Free delivery over ₹999 · GST invoices Get the appPrices incl. GST
Geekobot
Snap & SendNEWGeeko AIWhere's myOrder
Log in
Products
  • Projects
    • Component guidesHow parts work, with code you can run
    • Learning pathsFrom your first LED to your first robot
    • Workshops & eventsOnline sessions for makers and classes
    • ElectrolarkFree guided builds, simulator and certificates
    • Students & teachersStudent discount and classroom help
    • CommunityShare builds and ask other makers
    • CalculatorsOhm's law, LED resistor, 555 and 100+ more
    • Circuit builderWire parts and run the circuit, powered by Electrolark
    • Geeko AIAsk what to buy or how to wire it
    • Snap & SendPhotograph a part or list, we find it
    • Part finderAnswer a few questions, get the right part
    • Compatibility checkWill these two parts work together?
    • Compare partsSpecs side by side
    • Business & bulk ordersGST invoices, credit and volume prices
    • Request a quotationSend your list, get a quote
    • Classroom kitsPer-student kits and lab bundles
    • Gift cardsFor students, teams and events
  • Atal Tinkering Lab
BOM to cart
Geekobot

Components, kits and know-how for makers, students, engineers, labs and businesses across India.

Ask Geeko AIOrders, parts and projects, any timeEmail supportReply within 1 working dayGet the Geekobot appAdd it to your home screen, free

Follow us

Shop

  • Boards & SBCs
  • Sensors & Modules
  • IoT & Wireless
  • Drone & FPV
  • 3D Printing
  • Filaments & Resins
  • Motors & Drivers
  • Power & Batteries
  • Semiconductors
  • Passive
  • Displays & LEDs
  • Switches & Relays
  • Wires & Cables
  • Prototyping
  • Tools & Test
  • Robotics
  • STEM Kits
  • Atal Tinkering Lab
  • Mechanical Parts
  • Audio

Orders

  • Track your order
  • Help & support
  • Shipping and delivery
  • Refunds and cancellation
  • Contact us

Learn

  • Projects
  • Geeko AI project assistant
  • Learning paths
  • Guides
  • Calculators
  • Electrolark: free guided builds

Part tools

  • Part finder
  • Compare parts
  • Will it work with my board?

Institutions

  • Classroom kits
  • Atal Tinkering Lab
  • Students & teachers
  • Workshops & Events

Business

  • Business & education
  • Request a quotation
  • BOM bulk upload
  • Quick order by SKU

Company

  • About Geekobot
  • Community
  • Gift cards
  • Terms & conditions
  • Privacy policy
  • Product directory
  • Sitemap

© 2026 Geekobot, a trade name of OLatus Systems Private Limited. All rights reserved.

20, 1st Floor, Neeladri Complex, 10th Cross, Sampige Rd, 2nd Main, Malleshwaram, Bengaluru, Karnataka 560003 · GSTIN 29AACCO0462F1ZM

+91 91810 15607 · connect@geekobot.in · Monday to Saturday, 10 AM to 2 PM IST

UPI · CARDS · NETBANKING · GST INVOICES

ShopProjectsGeeko AIGuides
Compare 0 parts →
Log in

Shop by category

Shop all components
  • Boards & SBCs1,910 products
    • Alternative Single Board Computers
    • Arduino Ecosystem
    • FPGA & Logic Boards
    • Microcontroller & Wireless Boards
    View all
  • Sensors & Modules4,701 products
    • Biomedical & Heart Rate
    • Current, Voltage & Power
    • Force, Weight & Pressure
    • Gas, Weather & Environmental
    View all
  • IoT & Wireless2,314 products
    • RF Modules
    • RFID & NFC
    • Antennas & RF Accessories
    • Cameras & Smart Vision
    View all
  • Drone & FPV3,558 products
    • Flight Control & Navigation
    • FPV Video & Optics
    • Frames & Structural Parts
    • Motors & Propulsion
    View all
  • 3D Printing2,204 products
    • 3D Printers
    • 3D Scanners & Digitizers
    • Laser Engravers & Cutters
    • Material Management & Upgrades
    View all
  • Filaments & Resins1,472 products
    • Filaments
    • Photopolymer Resins
    View all
  • Motors & Drivers463 products
    • BLDC Motor Drivers
    • DC & Geared Motors
    • DC Motor Drivers
    • Linear Actuators & Solenoids
    View all
  • Power & Batteries557 products
    • Battery Holders & Connectors
    • Breadboard Power
    • Chargers & BMS
    • DC-DC Converters
    View all
  • Semiconductors295 products
    • Diodes & Rectifiers
    • Interface & RF Encoder ICs
    • Logic ICs (74xx)
    • Logic ICs (CD4000)
    View all
  • Passive67 products
    • Capacitors
    • Circuit Protection
    • Crystals & Oscillators
    • Inductors
    View all
  • Displays & LEDs572 products
    • 7-Segment & Dot Matrix
    • Addressable LEDs
    • Character LCDs
    • Graphic LCDs
    View all
  • Switches & Relays184 products
    • Keypads & Touch
    • Push Buttons & Tactile
    • Relay Modules
    • Relays
    View all
  • Wires & Cables233 products
    • Board-to-Wire Connectors
    • Crimp & Splice
    • Headers & Dupont
    • Heat Shrink & Sleeving
    View all
  • Prototyping101 products
    • Breadboards
    • Interface Modules
    • PCBs & Perfboards
    View all
  • Tools & Test717 products
    • Bench Power Supplies
    • Hand Tools
    • Measuring Tools
    • Meters & Testers
    View all
  • Robotics180 products
    • Humanoid & Legged Robots
    • Robot Chassis & Platforms
    • Robotic Arms & Grippers
    • Wheels & Casters
    View all
  • STEM Kits268 products
    • Arduino Learning Kits
    • Coding & IoT Kits
    • Early Coding (Ages 3-8)
    • Invention Kits
    View all
  • Atal Tinkering Lab196 products
    • Package 1: Electronics, Robotics, IoT and Sensors
    • Package 2: Rapid Prototyping Tools
    • Package 3: Mechanical, Electrical and Measurement Tools
    • Package 4: Power Supply, Accessories and Safety Equipment
    View all
  • Mechanical Parts212 products
    • Bearings
    • Brackets & Mounts
    • Couplers
    • Fasteners & Standoffs
    View all
  • Audio109 products
    • Amplifier Modules
    • Buzzers & Sirens
    • Speakers
    View all
  1. Home
  2. ›Guides
  3. ›Sensors
  4. ›LDR Light Sensors
Step 2 of 18 in Sensors and measurementPart of a learning path.
Next

Component guide · Beginner · 3 min read

LDR Light Sensors

Photoresistor Wiring, Dividers and Code

By Geekobot Learning Team · Updated 24 Oct 2026

I'm using
Wiring, code and the Run it panels follow your board.
On this page
Short answerHow an LDR worksWiring an LDR to an analog pinChoosing the fixed resistorLDR modules with digital outputWhen to use a real light sensorTry itCommon mistakesFAQsParts and next steps
Short answer

An LDR (light-dependent resistor or photoresistor) has high resistance in the dark, about 1 MΩ, and low resistance in bright light, under 1 kΩ. Put it in a voltage divider with a 10 kΩ resistor and read the midpoint with an analog pin to get a light level. It is cheap and simple but slow and uncalibrated; for real lux values use a BH1750 or TSL2561 sensor.

Key specs at a glance

Part
GL5528 and GL5516 are the common 5 mm LDRs
Dark resistance
About 1 MΩ or more
Bright resistance
About 10 to 20 kΩ at 10 lux, under 1 kΩ in sunlight
Response time
Tens of milliseconds, slower in the dark
Divider resistor
10 kΩ is a good general value
Module version
LM393 board with digital threshold and analog out
01

How an LDR works

The zigzag track on an LDR is cadmium sulphide, a semiconductor whose resistance falls as more light hits it. It has no polarity and no power pins: it is just a resistor that changes with light. To turn that resistance into a voltage a microcontroller can read, you combine it with a fixed resistor as a voltage divider.

02

Wiring an LDR to an analog pin

Connect the LDR from the supply (5 V on an Uno, 3.3 V on ESP32 and Pico) to the analog pin, and a 10 kΩ resistor from the analog pin to ground. Brighter light lowers the LDR's resistance and raises the voltage at the pin. Swap the two parts to invert the behaviour.

Automatic night light · Arduino C++Verify & upload in Electrolark
const int LDR = A0;   // ESP32: GPIO 34
const int LED = 9;

void setup() {
  pinMode(LED, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  int light = analogRead(LDR);          // 0 (dark) to 1023 (bright) on an Uno
  Serial.println(light);
  digitalWrite(LED, light < 300);       // on when dark; tune the number for your room
  delay(100);
}
03

Choosing the fixed resistor

The divider is most sensitive when the fixed resistor is close to the LDR's resistance at the light level you care about. For a room-light switch, 10 kΩ works. For detecting the difference between bright sun and shade, use 1 to 4.7 kΩ. For low-light detection, 47 to 100 kΩ. Measure the LDR with a multimeter in the real conditions and pick a resistor near that value.

04

LDR modules with digital output

The three-pin modules add an LM393 comparator and a trimmer. D0 goes LOW when light crosses the threshold you set, which is handy for a simple day/night switch without an analog pin. The four-pin version also exposes A0.

05

When to use a real light sensor

SensorMeasuresInterfaceChoose it for
LDRRelative light levelAnalogNight lights, simple light followers, cost
BH1750Lux, 1 to 65,535I2CWeather stations, plant light logging
TSL2561 / TSL2591Lux plus IR, wide rangeI2CPrecise indoor and outdoor light
VEML7700Lux, high accuracyI2CSmart lighting, displays that auto-dim
Photodiode / phototransistorFast light pulsesAnalogBeam break, tachometers, data
LDR
Measures:
Relative light level
Interface:
Analog
Choose it for:
Night lights, simple light followers, cost
BH1750
Measures:
Lux, 1 to 65,535
Interface:
I2C
Choose it for:
Weather stations, plant light logging
TSL2561 / TSL2591
Measures:
Lux plus IR, wide range
Interface:
I2C
Choose it for:
Precise indoor and outdoor light
VEML7700
Measures:
Lux, high accuracy
Interface:
I2C
Choose it for:
Smart lighting, displays that auto-dim
Photodiode / phototransistor
Measures:
Fast light pulses
Interface:
Analog
Choose it for:
Beam break, tachometers, data
06

Try it: Voltage divider calculator

Change the values and the diagram and results update as you type.

07

Common mistakes to avoid

  • !Connecting the LDR alone to an analog pin without a divider resistor.
  • !Using 5 V on the divider with an ESP32 or Pico, which can put 5 V on the ADC pin.
  • !Expecting lux values; an LDR gives an uncalibrated relative number.
  • !Placing the LDR where the project's own LEDs shine on it, which causes oscillation.
  • !Using it for fast pulses; LDRs respond slowly.
08

Frequently asked questions

What is an LDR used for?

Detecting light level: automatic street and night lights, solar trackers, light-following robots, laptop-style display dimming and counting objects passing a beam.

Does an LDR have polarity?

No. It is a resistor and works either way round.

Which resistor should I use with an LDR?

10 kΩ for general use. Lower (1 to 4.7 kΩ) to distinguish bright light levels, higher (47 to 100 kΩ) for dim conditions.

Can I use an LDR with an ESP32?

Yes. Power the divider from 3.3 V and read it on an ADC1 pin (GPIO 32 to 39) so it works alongside Wi-Fi.

LDR vs BH1750: which should I use?

An LDR for a cheap on/off light switch; a BH1750 when you want actual lux values that are consistent between sensors.

Parts for this guide

  • Digital LDR Light Sensor Module for Arduino – LM393 Comparator, Adjustable Sensitivity
    ₹31View
  • CJMCU APDS-9930 Proximity & Ambient Light Sensor Module – I2C Interface
    ₹99View
  • Resistor Assortment Kit (30 Values)
    ₹33View
Shop Light & Optical SensorsShop Resistors

Calculators

Voltage divider calculator

Terms in this guide

Voltage dividerTwo resistors in series that output a fixed fraction of the input voltage.ADCAnalog-to-digital converter: turns a voltage into a number. A 10-bit ADC gives 0 to 1023; a 12-bit ADC gives 0 to 4095.LuxThe unit of illuminance, or how much light falls on a surface. Full daylight is around 10,000 to 100,000 lux; a lit room is about 300 to 500 lux.ComparatorA circuit that compares two voltages and outputs HIGH or LOW depending on which is larger. Sensor modules use one (often an LM393) to produce their digital output.PhotoresistorAnother name for an LDR: a resistor whose resistance drops as light increases.

Projects that use it

Put this into practice: 34 step-by-step builds in our project library use parts from this guide.

Beginner · 45 minutesAutomatic dusk-to-dawn lightView projectBeginner · 1–2 hoursWi-Fi dusk light with manual overrideView projectBeginner · 45 minutesPico fading night light (MicroPython)View project
Browse all 34 projects

Keep learning

Component guideBeginnerResistors ExplainedWhat resistors do, how to read 4- and 5-band colour codes and SMD codes, Ohm's law, power ratings, standard values and uses: LEDs, pull-ups, dividers.4 min read · Passive ComponentsComponent guideBeginnerLEDs ExplainedAn LED (light-emitting diode) lights when current flows from its longer leg (anode, +) to its shorter leg (cathode, -).3 min read · Displays & LEDsComponent guideBeginnerESP32 GuideThe ESP32 is a low-cost 3.3 V microcontroller from Espressif with built-in Wi-Fi and Bluetooth, used for IoT devices, smart-home controllers and web dashboards.5 min read · Boards & MicrocontrollersComponent guideBeginnerArduino UnoThe Arduino Uno is a beginner-friendly microcontroller board that reads sensors and controls LEDs, motors and relays using simple C++ programs called sketches.5 min read · Boards & Microcontrollers

Sources

  • GL55 series photoresistor datasheet
  • BH1750FVI datasheet (Rohm)
  • LM393 datasheet (Texas Instruments)

Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.

On this page
Short answerHow an LDR worksWiring an LDR to an analog pinChoosing the fixed resistorLDR modules with digital outputWhen to use a real light sensorTry itCommon mistakesFAQsParts and next steps
Need a hand?Ask Geeko AI which part fits your project, or talk to the Geekobot team.Ask Geeko AIHelp & support

Parts for this guide1 item · ₹156

Moonlex - DC Day Light Sensor (LDR)

Run itChange the inputs and watch the output
Night light OFF
Serial monitor9600 baud
612

A simulation of the sketch above, so you know what to expect. Real readings vary with your parts and wiring.

Ask the Community

Ask a question