#include <WiFi.h>
#include <Wire.h>

const char* ssid = "Wokwi-GUEST";
const char* password = "";

const int ledPin_blue = 18; 
const int ledPin_yellow = 19; 

const int luxPin = 34;  
const float gama = 0.7;
const float rl10 = 50;
void setup() {
  Serial.begin(115200);
  WiFi.begin(ssid, password);

  pinMode(ledPin_blue, OUTPUT);
  pinMode(ledPin_yellow, OUTPUT);
  pinMode(luxPin, INPUT);

  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Menghubungkan ke WiFi...");
  }
  Serial.println("Terhubung ke WiFi!");
}

void loop() {
  int luxValue = analogRead(luxPin);
  luxValue = map(luxValue, 4095, 0, 1024, 0);
  float voltase = luxValue / 1024.*5;
  float resistansi = 2000 * voltase / (1-voltase/5);
  float lux = pow(rl10*1e3*pow(10,gama)/resistansi,(1/gama));

  Serial.print("Lux: ");
  Serial.println(lux);

  if (lux < 500) {
    digitalWrite(ledPin_blue, HIGH);
    digitalWrite(ledPin_yellow, LOW);
  } else {
    digitalWrite(ledPin_blue, LOW);
    digitalWrite(ledPin_yellow, HIGH);
  }
  delay(1000);
}
$abcdeabcde151015202530fghijfghij