void setup() {
// put your setup code here, to run once:
pinMode(1, OUTPUT);
}
// These constants should match the photoresistor's "gamma" and "rl10" attributes
const float GAMMA = 0.7;
const float RL10 = 50;
void loop() {
// put your main code here, to run repeatedly:
int LUXval=analogRead(A1); // reading the sensor value
//Convert the analog value into lux value
float voltage = LUXval / 1024.0 * 5;
float resistance = 2000 * voltage / (1 - voltage / 5);
float lux = pow(RL10 * 1e3 * pow(10, GAMMA) / resistance, (1 / GAMMA));
// making the desicion
if (lux<800){
digitalWrite(1, HIGH);
delay(500);
}
else{
digitalWrite(1, LOW);
delay(500);
}
}