#define DARK HIGH
#define LIGHT LOW
const int RELAY_PIN = 15;
const int LDR_PIN = 16;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(LDR_PIN, INPUT);
pinMode(RELAY_PIN, OUTPUT);
digitalWrite(RELAY_PIN, LOW);
// Serial.println("Hello, ESP32!");
}
void loop() {
// put your main code here, to run repeatedly:
int lightState = digitalRead(LDR_PIN);
if (lightState == DARK) {
digitalWrite(RELAY_PIN , HIGH);
} else {
digitalWrite(RELAY_PIN , LOW);
}
delay(100); // this speeds up the simulation
}