Source: https://mokxi.com/parts/ldrmodule
Updated: 2026-11-16

Part

# Photoresistor sensor module

The LDR on a board with a comparator: an analog level, and a digital output set by its trimmer.

See every part

- 4 pins
- 4 settings
- In 9 projects

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

At a glance

## The Photoresistor sensor module in brief

What it is, and every setting the properties panel gives it.

The photoresistor sensor module puts a light-dependent resistor on the same four-pin LM393 comparator board as the flame sensor, with pins VCC, GND, DO and AO and a supply of 3.3 to 5 volts, so it wires straight to an Uno or an ESP32. The board hangs a 10 kilohm resistor from VCC to AO and the cell from AO to ground, which means AO falls as the light rises, the reverse of what most people expect. DO is the comparator’s open-collector output with its own 10 kilohm pull-up: high in the dark and low in the light, with the DO lamp lit while it is low. Mokxi’s cell is 50 kilohms at 10 lux with a gamma of 0.7, both properties, so AO crosses half the supply near 100 lux, right where the default threshold of 0.5 sits. The slider sets the light in lux, and AO is driven with the divider’s own source resistance. Reading DO with analogRead gives only 0 or the supply. The cell’s response time and the chatter a real board shows right at the threshold are not modeled.

Family

Sensors

Pins

4

threshold

0.5

rl10

50

gamma

0.7

lux

500

Pins

## 4 pins

Named as the editor names them, so a wire lands where you expect it.

Pin

Role

What it does

VCC

Input or output

Supply, 3.3 to 5 V.

GND

Input or output

Ground.

DO

Output

Digital out: high when it is darker than the trimmer's setting, low when lighter.

AO

Output

Analog out: the LDR under a 10 k resistor, lower in more light.

How to use it

## How to use a photoresistor module with an Arduino

Wire VCC to 5 V, GND to GND, DO to pin 2 and AO to A0. Use DO when you want a switch: digitalRead() gives HIGH in the dark and LOW in the light, and the blue trimmer sets where it changes, about 100 lux out of the bag. Use AO when you want a number, remembering that it reads lower as the light gets brighter.

The dusk switch does both: it turns the lamp on pin 13 on when DO goes high and prints the AO reading twice a second, so you can see which number the trimmer is set to. Turn the trimmer, not the code, to move the switching point.

Part pin

Board pin

VCC

5 V

GND

GND

DO

Pin 2

AO

A0

Powered from 3.3 V on an ESP32 or a Pico, AO swings across that supply instead, and the threshold is still the same fraction of it.

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

Both outputs of the module

How it is modeled

## What is true about the Photoresistor sensor module, here

In its help article’s own words: what the simulation gets right, and where it stops.

### Modeled

The divider. 10 k from VCC to AO and the cell from AO to ground, so AO
is the supply times R / (R + 10 k), and it drives that voltage with the divider's
own source resistance.

The cell's curve, R = rl10 x (10 / lux) ^ gamma, a megohm in the dark: 50 k at
10 lux, about 10 k at 100 lux, where AO crosses half the supply.

The comparator. The LM393 compares AO with the trimmer and pulls DO low
through its open collector while AO is below it; high is the board's 10 k
pull-up. That is the same board the flame and rain sensors
stand on.

### Not modeled

The cell's response time and light history, the LM393's lack of hysteresis (a real
board chatters with the light right at the threshold), and color: lux here is the
eye's lux.

From Photoresistor sensor module, in full.

Projects

## See the Photoresistor sensor module in a project

9 built-in projects use it. Each opens in the editor, already wired.

Boards

## The boards it is shown on

Each of these 2 boards has a built-in project with the Photoresistor sensor module in it.

- Arduino Uno R3
- ESP32-C3-DevKitM-1

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.

Filament lamp

A tungsten bulb in a holder: an inrush when it is switched on cold, tens of milliseconds to warm up, and dim on half its voltage.

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; real internet through the Cloud panel’s switch), 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.

Raspberry Pi 4 Model B

Raspberry Pi 4 Model B: the 40-pin header, driven by main.py with RPi.GPIO or gpiozero.

See every part

## Wire up the Photoresistor sensor module

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

Start building free Open the editor
