int ldr = 35;
int led = 26;
int ldrreading = 0;
int thresh = 800;
int ledbright = 0;
const float GAMMA = 0.7;
const float RL10 = 50;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(ldr, INPUT);
pinMode(led, OUTPUT);
Serial.println("Hello, ESP32!");
}
void loop() {
int analogValue = analogRead(ldr);
float voltage = analogValue / 1024. * 5;
float resistance = 2000 * voltage / (1 - voltage / 5);
float lux = pow(RL10 * 1e3 * pow(10, GAMMA) / resistance, (1 / GAMMA));
Serial.println(analogValue);
delay(500);
Serial.println(lux);
delay(1000);
if(analogValue>200)
digitalWrite(led, HIGH);
else
digitalWrite(led,LOW);
delay(10); // this speeds up the simulation
}