Photoresistor / LDR (Light Dependent Resistor)

A Photoresistor, or Light Dependent Resistor (LDR), is a passive analog sensor whose electrical resistance decreases as the intensity of ambient light incident on its surface increases…

Sensors8 blocksMicroPythonC++
LDR Module

At a glance

Pins and properties exactly as the circuit editor and simulator define this part. The text below explains how to use them.

Pinout

Pinout of the LDR Module, drawn as in the circuit editor. Select a label to see that pin in the table below.

Pins

Pins of this part
PinLabelType
AOOUTAnalog out
GNDGNDGround
VCCVCCPower in

Properties

What you can change in the Property Inspector.

Properties of this part
PropertyRange or choicesDefault
Light Level0 to 1023512
Threshold0 to 1023512

Photoresistor / LDR

A Photoresistor, or Light Dependent Resistor (LDR), is a passive analog sensor whose electrical resistance decreases as the intensity of ambient light incident on its surface increases (photoconductivity). In Open Maker Studio, it's used for automatic night lights, solar tracking, and general light-level measurements.


1. Schematic Symbol

Standard photoresistor symbol — a resistor with two inward-pointing arrows representing incoming light:

1 2

2. What OMS Actually Simulates

OMS's Photoresistor component is a bare 2-pin LDR only (pins simply named 1/2) — there's no simulated 3-pin LDR module (VCC/GND/AO/DO with an onboard comparator) as a separate part in the Circuit Canvas. Its resistance model is calibrated against a real part, the GL5528 CdS photoresistor (Handson Technology GL55 series datasheet):

  • Dark resistance: 1MΩ (the datasheet's own minimum spec).
  • Bright resistance: 8kΩ (the low end of the datasheet's 8–20kΩ @10lux range).
  • The resistance curve between those two points is a real power-law ("gamma") interpolation, not a straight linear ramp — matching the real datasheet's documented log-log relationship between illuminance and resistance. A linear model would have compressed the "interesting" 1kΩ–100kΩ range most analogRead()-based light-sensing code actually lives in into the last ~20% of the control's travel; the real power-law curve spreads it out realistically instead.

[!NOTE] The digital-output Blockly blocks target real hardware, not the simulator. sensor_ldr_ read_digital/sensor_ldr_on_digital generate code for a real 3-pin LDR module's comparator output pin — that code is genuine and will run correctly on real hardware, but there's no component in OMS's Circuit Canvas with a DO pin to wire up and test it against in simulation. Only the analog voltage-divider behavior (Section 3) is actually simulated.


3. How it Works & Wiring

A bare photoresistor requires a series resistor (typically 10 kΩ10\ \text{k}\Omega) to form a voltage divider circuit so that the change in resistance can be measured as a change in voltage by the microcontroller's ADC:

  • VCC-Side Wiring (Active Bright):
    • Connect one pin of the LDR to VCC.
    • Connect the other pin of the LDR to the ADC pin (e.g., A0) and to GND through a 10 kΩ10\ \text{k}\Omega resistor.
    • Result: Voltage increases as light level increases.
  • GND-Side Wiring (Active Dark):
    • Connect one pin of the LDR to GND.
    • Connect the other pin of the LDR to the ADC pin and to VCC through a 10 kΩ10\ \text{k}\Omega resistor.
    • Result: Voltage decreases as light level increases (useful for night-activation triggers).

4. Component Properties (Property Inspector)

When you select the Photoresistor on the canvas, you can modify the following parameter in the Property Inspector panel:

  • Light Level (lightLevel): Sets the raw simulated light level driving the real power-law resistance curve from Section 2.
    • Default: 512 (mid-scale)
    • Range: 0 (darkness, 1MΩ) to 1023 (bright, 8kΩ)

There's no separate dark/bright resistance override — those two endpoints (1MΩ/8kΩ) are fixed constants matching the real GL5528 datasheet, not user-adjustable props.


5. Supported Blockly Blocks

Drawing the blocks…

6. Simulator Behavior

  • On-Canvas Drag Slider: The component itself renders a vertical brightness slider (bright ☀ at the top, dark 🌑 at the bottom) directly on its canvas graphic — drag it during simulation to change lightLevel in real time, in addition to using the Property Inspector.
  • Real-time Resistance Readout: While a simulation is running, OMS renders a live text overlay on the component showing its current resistance (e.g. 142.5kΩ) — not a hover-only tooltip, and not a light-percentage readout; only resistance is displayed.
Photoresistor / LDR (Light Dependent Resistor) — OMS Parts