LDR Circuit: Which Way Round Your Divider Goes

📅
✍️ By CircuPilot Team
← Back to Blog Hub

A photoresistor is the cheapest sensor in electronics and the one most often wired without thinking. It has two pins, no polarity, and no datasheet worth reading — which hides the one decision that determines what your circuit does.

It is a resistor, not a sensor output

This is the part that trips people up. An LM35 gives you a voltage. A photoresistor gives you a resistance, and a resistance is not something a microcontroller can read.

Connect an LDR straight to an analog pin and you get nothing useful. It needs a fixed resistor to form a voltage divider, and the junction between the two is the thing you measure.

5V ──[ LDR ]──┬──[ 10k ]── GND
              │
            to A0

That is the entire circuit. Two components, and one decision.

The decision: which one goes on top

Both arrangements work. They do opposite things.

LDR on top (as drawn above): more light lowers the LDR's resistance, so the junction is pulled closer to the supply. Voltage rises with light.

LDR on the bottom, with the fixed resistor between the supply and the junction: more light lowers the LDR's resistance, so the junction is pulled closer to ground. Voltage falls with light.

Neither is correct in general. A light meter usually wants the first, because more light reading as a bigger number is what people expect. A night light wants the second, because then "dark" is a high reading and the comparison is the obvious way round. Pick deliberately, and write down which you picked — a sensor reading backwards is a genuinely confusing bug because the circuit looks fine.

Real numbers

A 10 kΩ-at-10-lux cell with a 10 kΩ fixed resistor on 5 V, LDR on top, simulated with ngspice:

LightLDR resistanceVoltage at A0
0.1 lx — full dark251 kΩ0.191 V
1 lx — moonlight50 kΩ0.832 V
10 lx — dim room10 kΩ2.500 V
100 lx — normal room2 kΩ4.168 V
1000 lx — overcast day398 Ω4.809 V
10000 lx — outdoor shade100 Ω4.951 V

Two things are worth noticing in that table, and both matter more than the exact figures.

The response is logarithmic, not linear. Going from 10 lx to 100 lx — a tenfold change — moves the reading 1.7 V. Going from 1000 lx to 10000 lx, also tenfold, moves it 0.14 V. The circuit is sensitive in dim light and nearly blind in bright light. That is the cell, not a fault.

The midpoint lands where the two resistances match. At 10 lx the LDR is 10 kΩ, the fixed resistor is 10 kΩ, and the output is exactly half the supply. That is not a coincidence — it is the rule for choosing the fixed resistor.

Choosing the fixed resistor

The divider is most sensitive where the two resistances are similar, so match the fixed resistor to the LDR's resistance in the light level you care about.

If your sensor decides between a lit room and a dark one, 10 kΩ is right — it puts the transition in exactly that range. If it has to work outdoors in daylight, 10 kΩ is wrong: the cell sits at a few hundred ohms there and the divider parks near the supply rail, moving barely at all. That is the actual cause of the most common complaint about these circuits — "my reading barely changes" — and it is a component choice, not a code problem.

Reading it with a microcontroller

const int LDR_PIN = A0;
const int THRESHOLD = 400;      // found by experiment, not by formula

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  int light = analogRead(LDR_PIN);
  digitalWrite(LED_BUILTIN, light < THRESHOLD ? HIGH : LOW);
  delay(50);
}

That is a night light: with the LDR on top, a low reading means dark, so the LED turns on. Simulated with the table above, the LED switches below about 1.95 V — around 1 lux, genuine darkness.

Do not try to convert the reading to lux. The response is logarithmic, the tolerance on these cells is enormous — two from the same bag can differ by a factor of two — and they drift with age and temperature. Any formula you write is calibrated to one specific cell on one specific day. Compare against a threshold you found by experiment, and if you truly need absolute light, use a digital sensor with a calibrated output.

Add hysteresis if the output matters. At exactly the threshold, noise makes the reading cross back and forth and the light flickers. Turn on below 380 and off above 420, rather than switching on a single number.

Where it goes wrong

The reading is stuck near 0 or near 5 V. The fixed resistor is far from the LDR's resistance in your light range. Measure the cell in the light you care about and match it.

The reading is backwards. The LDR is on the other side of the divider from what you assumed. Swap it, or invert the comparison — but pick one and write it down.

The reading jitters. Average a few samples, or add a 100 nF capacitor from the junction to ground. Both cost nothing, and the capacitor also helps the ADC by giving it a low-impedance source to sample from — the same requirement described in why a voltage divider drops under load.

Try it

Open the simulator, place a photoresistor from the Sensors palette and a 10 kΩ resistor in series across 5 V, and connect the junction to an analog pin. The sensor has ± buttons on the canvas: change the light and watch the reading move — including watching it stop moving once you get past a thousand lux, which is the lesson that table teaches faster than any explanation.

If you want the other common sensor first, the LM35 and its 0.5 °C trap is the temperature equivalent, and it does give you a voltage directly — which makes the contrast a useful way to understand both.

Frequently asked questions

Does a photoresistor produce a voltage?

No. It is a resistor whose value changes with light, so on its own it gives you nothing to read. It has to be paired with a fixed resistor to form a voltage divider; the junction between them is what you connect to an analog pin.

Which way round should the LDR go?

Either, and the choice is the design. With the LDR on top, between the supply and the junction, the voltage rises as light rises. With the LDR on the bottom, between the junction and ground, the voltage falls as light rises. A light meter usually wants the first, a night light the second.

What resistor should I pair with an LDR?

10 kΩ is the standard choice because it puts the midpoint in ordinary indoor light, where a typical cell also sits near 10 kΩ. Match the fixed resistor to the resistance your LDR has in the light level you care about most — that is where the circuit is most sensitive.

Can I convert an LDR reading to lux?

Not reliably. The response is logarithmic, every cell differs by a wide tolerance, and they drift with age and temperature. Compare against a threshold instead. If you genuinely need lux, use a digital light sensor with a calibrated output.

Why does my LDR reading barely change?

Usually the fixed resistor is far from the LDR's resistance in your light range, so the divider sits near one rail and stays there. Check what your cell measures in the light you actually care about and match the fixed resistor to it.