#define AO_PIN 39 // ESP32's pin GPIO36 connected to AO pin of the ldr module
int ldrValueLeft;
float ldrValueLeft_updated;
void setup() {
// initialize serial communication
Serial.begin(9600);
}
void loop() {
getLdrValue();
int lightValue = analogRead(AO_PIN);
Serial.println("ldrValueLeft:");
Serial.println(ldrValueLeft);
Serial.println("ldrValueLeft_updated:");
Serial.println(ldrValueLeft_updated);
delay(2000);
}
// accessing the ldr voltage value
void getLdrValue(){
int ldrValueLeftRaw = analogRead(AO_PIN);
// int ldrValueRightRaw = analogRead(AO_PIN_Right);
ldrValueLeft = (ldrValueLeftRaw);
// ldrValueRight = (ldrValueRightRaw);
ldrValueLeft_updated = (float) (ldrValueLeftRaw - 32)/4031; // note that the max voltage for min intensity is 32, min voltage for mat intensity is 4063
// drValueRight_updated = (ldrValueRightRaw - 32)/4031;
// String(ldrValueLeft, 2).toCharArray(ldrLeftArr, 6);
// String(ldrValueRight, 2).toCharArray(ldrRightArr, 6);
}