Photoresistor (LDR) sensor module
|VCC||Positive power supply|
|lux||Initial light value (lux)||"500"|
|threshold||Digital output threshold voltage||"2.5"|
|rl10||LDR resistance @ 10lux (in kilo-ohms)||"50"|
|gamma||Slope of the log(R) / log(lux) graph||"0.7"|
The photoresistor sensor module includes a LDR (light-dependant resistor) in series with a 10K resistor. The AO pin is connected between the LDR and the 10K resistor.
The voltage on the AO pin depends on the illumination - that is the amount of light that falls on the sensor. You can read this voltage by connecting the AO pin of the photoresistor sensor to an analog input pin and then using the
There are two parameters that control the sensitivity of the LDR: rl10 and gamma. rl10 is the resistance of the LDR at illumination level of 10 lux. The gamma value determines the slope of the log(R) / log(lux) graph. You can usually find these two values in the datasheet of the LDR.
The following table shows the relationship between the illumination level (lux), resistance (R), and the voltage level on the AO pin when gamma = 0.7 and rl10 = 50 (the default values):
|Condition||Illumination (lux)||LDR Resistance||Voltage*||analogRead() value|
* When VCC = 5V
** Measured one meter away from the monitor
The following code to convert the return value of
analogRead() into a illumination value (in lux):
The digital output ("DO") pin goes high when it's dark, and low when there's light. On the physical sensor, you tweak the small on-board potentiometer to set the threshold. In the simulator, use the "threshold" attribute to set the threshold voltage. The default threshold is 2.5 volts, or about 100 lux.
The bottom LED ("DO LED") is connected to the digital output, and lights whenever the DO pin goes low. In other words, it lights when the sensor is illuminated.