Class LDR

All Implemented Interfaces:
InputEventListener<AnalogInputEvent>, java.io.Closeable, java.lang.AutoCloseable, java.lang.Runnable

public class LDR
extends AnalogInputDevice

Generic Photoresistor / Light-Dependent-Resistor (LDR).
Wiring:

 vRef     vLDR       GND
   |        |         |
   +---R1---+---LDR---+
 

When there is a lot of light the LDR has low resistance (vLdr ~ 0V). When it is dark the resistance increases (vLdr ~ vRef).

vLDR = vRef * (rLDR / (rLDR + R1))

Given R1 = 10,000ohm and vRef = 5v:
When dark, if rLDR == 100,000 Ohm: vLDR = 5 * (100,000 / (100,000 + 10,000)) = 4.54V
When light, if rLDR == 100 Ohm: vLDR = 5 * (100 / (100 + 10,000)) = 0.0495V

rLDR = R1 / (vRef / vLDR - 1)

Given R1 = 10,000ohm and vRef = 5v:
When dark, if vLDR=4V: rLDR = 10,000 / (5 / 4 - 1) = 40,000 Ohm
When light, if vLDR=1V: rLDR = 10,000 / (5 / 1 - 1) = 2,500 Ohm