Source: https://mokxi.com/parts/ldr
Updated: 2026-09-27

Part

# Light sensor

A light-dependent resistor, with a slider for how bright the room is.

or see every part

- 2 pins
- 3 properties

Drawn live by the editor's own code, at the size you see it.

Reference

## Every one of its 2 pins

Pin

What it does

1

One leg.

2

The other leg.

This part

## What it does

A light-dependent resistor, or photoresistor, is a resistor whose value depends on the light falling on it: under a thousand ohms in daylight, tens of kilohms in a room, and a megohm or more in the dark. It has no supply pin and no output, so it is always wired in a divider with a fixed resistor and a board reads the voltage in the middle. Mokxi’s part follows the GL5528 datasheet curve, resistance falling as a power of the light level, with a cap in full darkness, and all three numbers are properties, so a GL5537 is the same part with a different value at 10 lux. The light level is a slider on the part, in lux. It does not model the cell’s slow response, the twenty or thirty milliseconds a real one takes to follow a change, or its long recovery after bright light.

How to use it

## How to use an LDR with an Arduino

An LDR needs a partner: put it between 5 V and an analog pin, and a 10 k resistor between that pin and GND. analogRead() then goes up as the light comes up. Pick the fixed resistor near the LDR’s own resistance at the light level you care about, and switch on two thresholds with a gap between them, so the output does not flutter at dusk.

Part pin

Board pin

LDR

5 V and A0

10 k resistor

A0 and GND

On a 3.3 V board, run the divider from 3.3 V and scale the thresholds to its ADC range.

Click to open it in the editor

This is the simulator itself, running here. Click anything to open it in the editor.

Open this project in the editor Read the full tutorial

Reference

## The 3 properties you can set

Property

Default

What it means

r10

15000

resistance at 10 lux, 15 000 ohms by default (a GL5528).

gamma

0.6

the slope
of the resistance/light curve on log-log paper, 0.6 by default.

dark

1000000

the
resistance cap in full darkness, 1 000 000 ohms by default.

How it is modeled

## What is true about the Light sensor, here

### What is modeled

The curve is the datasheet's own: R(lux) = r10 x (10 / lux) ^ gamma, capped at
dark. With the GL5528 defaults that gives about 950 ohms in full daylight, 15 k in
a dim room, 60 k by candlelight and the megohm cap with the window covered. A
GL5537 is the same model with r10 set to 50 000, an order of magnitude up.

### Not modeled

No response time. A real cell takes twenty or thirty milliseconds to follow a step
and much longer to recover from bright light, the "light history effect" every
datasheet apologizes for, but nothing here runs fast enough for that lag to be the
thing that limits a circuit.

The power law is the datasheet's shape, not a fit to one cell: a real GL5528's gamma
drifts across the range rather than staying at 0.6, and the part-to-part spread on r10
is a factor of two or more, so the ohms here are the right order and the right slope
rather than a number to calibrate against. There is no noise, no temperature
coefficient (a real cell moves several percent across a room's range), no spectral
response (the slider is lux of some unspecified color), and no maximum voltage or
power. The resistance changes the instant the slider does.

From LDR (light-dependent resistor), in full.

Projects

## See the Light sensor in a project

Shown here on: Arduino Uno R3

Learn

## Where it turns up in a lesson

### In a learn article

- Arduino LDR Night Light (Photoresistor)
- Engineering Science Fair Project: How to Write It Up

More parts

## The rest of the bench

Every one of these is drawn and simulated the same way.

Full-size breadboard

A real 0.1 inch grid with the rails and the center channel, 63 columns wide.

Jumper wires

Drag from any pin or hole to any other. Corners snap, and you can drag them.

Power

A supply rail at the voltage you choose.

Ground

The other end of every circuit.

LED

Lights when current flows. Five colors, and the brightness is what your eye would see.

Resistor

Any value you like, with the color bands drawn to match.

ESP32-C3-DevKitM-1

A RISC-V board that runs your firmware at 160 MHz on the real memory map.

Pushbutton

A 12 mm tactile switch. Hold it while the simulation runs.

Raspberry Pi Pico

The RP2040 board on our own Cortex-M0+ core. Pick a program and press Run.

Raspberry Pi Pico W

Raspberry Pi Pico W (RP2040). The same board and the same pinout as a Pico, with the CYW43439 on it. The WiFi is simulated (no radio, no real internet), and the on-board LED, which hangs off that chip rather than off GP25, is driven through the same path. Everything else is the Pico.

STM32F411 Black Pill

The Black Pill on our own Cortex-M4 core. Pick a program and press Run.

BBC micro:bit V2

The nRF52833 board with its 5x5 LED matrix, buttons A and B and a speaker. Wire the rings to a breadboard.

See every part

## Wire up the Light sensor

Open the editor and push it into the breadboard. It is free, and it runs on your own machine.

Start building Open the editor
