- KEYWORDS: LDR,Light,Light Dependent Resistor,Photoresistor,Light,Sensor,GL5537
An LDR is a resistor that varies resistance with the amount of light shining on it. The GL5537 changes resistance from 25k in darkness to around 200 Ohms when lots of light shines on it.
Connect as follows:
10k Resistor | Sensor | Espruino |
---|---|---|
1st pin | 3.3v | |
1st Pin | 2nd pin | A1 |
2nd Pin | GND |
Note: any Analog pin will do.
You can then easily read the analog value. Because of the way the sensor is wired, the value you'll get will be near 0.5 in darkness, and 1 when there is a lot of light.
var light = analogRead(A1);
console.log(light);
- APPEND_USES: LDR