// Photoresistor Characteristics
const float GAMMA = 0.7;
const float RL10 = 50;


void setup() {
  Serial.begin(9600);
  pinMode(10, OUTPUT); 
}

void loop() {
  int analogValue = analogRead(A0);
  /*Reads the value from the specified analog pin. 
  In this case, the analog pin A0 is connected to the photoresistor sensor */
  
  float voltage = analogValue / 1024. * 5;

  float resistance = 2000 * voltage / (1 - voltage / 5);
  float lux = pow(RL10 * 1e3 * pow(10, GAMMA) / resistance, (1 / GAMMA));
  /*various calculations to get the luminosity value from the
  photoresistor sensor */
 


  if (lux > 50) {
      Serial.println("Light!");
      Serial.println("Luminosity: " + String(lux));
      digitalWrite(10, LOW);
       //if the luminosity is greater than 50, turn off the LED
  } else {
    Serial.println("Dark!");
    Serial.println("Luminosity: " + String(lux));
    digitalWrite(10, HIGH);
    //else, turn on the LED
  }
delay(2000);
    
}