// Nama : Alfianus Gatu 
// Nim : 19102173


//Mengukur intensitas cahaya dengan photoresistor dan ESP32 serta menampilkan 
//hasilnya pada serial monitor

const float GAMMA = 0.7;
const float RL10 = 50;

void setup(){
  Serial.begin(115200);
  pinMode(12, OUTPUT);
}
void loop(){
  int analogValue = analogRead(25);
  float voltage = analogValue * 5/4095.0;
  float resistance = 2000 * voltage / (1 - voltage / 5);
  float lux = pow(RL10 * 1e3 * pow(10, GAMMA) / resistance, (1 / GAMMA));
  Serial.print("Lux : ");
  Serial.println(lux);

  if (lux >= 50){
    Serial.print("Status: ");
    Serial.println("Terang");

  }else{
   Serial.print("Status: ");
   Serial.println("Gelap");
  }
  delay(100);

}