/*
* This ESP32 code is created by esp32io.com
*
* This ESP32 code is released in the public domain
*
* For more detail (instruction and wiring diagram), visit https://esp32io.com/tutorials/esp32-ldr-module
*/
#define AO_PIN 32 // ESP32's pin GPIO36 connected to AO pin of the ldr module
void setup() {
// initialize serial communication
Serial.begin(9600);
// set the ADC attenuation to 11 dB (up to ~3.3V input)
analogSetAttenuation(ADC_11db);
pinMode(5,OUTPUT);
}
void loop() {
int lightValue = analogRead(AO_PIN);
Serial.print("The AO value: ");
Serial.println(lightValue);
if(lightValue>500){
digitalWrite(5,1);
}
else{
digitalWrite(5,0);
}
}