#define led 12

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

void setup() {
  Serial.begin(9600);
  pinMode(led, 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");
    digitalWrite(led, HIGH);
  } else {
    Serial.print("Status: ");
    Serial.println("Gelap");
    digitalWrite(led, LOW);
  }
  delay(100);
}