LIGHT is a light intensity sensor unit with an adjustable photoresistor。
A photoresistor is a light-controlled variable resistor. The resistance of a photoresistor decreases with increasing incident light intensity, and vice versa. It exhibits photoconductivity which make it possiable to detect the varies based on Voltage, and use a AD to convert the digital data.
We add some extra work to strengthen the circult, a Dual Differential Comparators LM393, compares the differntial voltage between the photoresistor and the varistor. It could offer larger and accuracy range of light intensity.
The code below is incomplete. To complete code, please click here.
#include <M5Stack.h> // declaration uint16_t analogRead_value = 0; uint16_t digitalRead_value = 0; // initialization M5.begin(); dacWrite(25, 0);// disable the speak noise pinMode(26, INPUT);// LIGHT Pin setting // read data analogRead_value = analogRead(36);// read analog value of LIGHT digitalRead_value = digitalRead(26);
To get complete code, please click here.
|LIGHT Unit||AnalogSignal Pin||DigitalSignal Pin||5V||GND|