const float GAMMA = 0.7;
const float RL10 = 50;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
}
void loop() {
// put your main code here, to run repeatedly:
// ADC to Voltage
int adcValue = analogRead(15);
float voltage = (map(adcValue,0,4095,0,3300))/1000.0;
Serial.print("Nilai ADC : ");
Serial.print(adcValue);
Serial.print("\t Nilai Tegangan : ");
Serial.println(voltage);
// Membaca Sensor LDR
float adcLdr = analogRead(2);
float voltase = adcLdr / 4096. * 5;
float resistansi = 2000 * voltase / (1-voltase / 5);
float kecerahan =pow(RL10 * 1e3 * pow(10, GAMMA) /resistansi, (1/GAMMA));
Serial.print("Nilai ADC : ");
Serial.print(adcLdr);
Serial.print("\t Nilai Intensitas : ");
Serial.println(kecerahan);
delay(100); // this speeds up the simulation
}