//Susilo Dwi Pramono
//20200130168
int ldrPin = A0; // LDR pin
int ldrVal = 0; // Value of LDR
// LDR Characteristics
const float GAMMA = 0.7;
const float RL10 = 50;
void setup() {
Serial.begin(9600); // Initialise the serial monitor
}
void loop() {
ldrVal = analogRead(ldrPin); // Read the analog value of the LDR
float voltage = ldrVal / 1024. * 5;
float resistance = 2000 * voltage / (1 - voltage / 5);
float lux = pow(RL10 * 1e3 * pow(10, GAMMA) / resistance, (1 / GAMMA));
Serial.println(lux); // Show the value in the serial monitor
delay(1000); // Pause 1000ms
}