/* Calibration of LDR values of Ohms to LUX values using a LUXmeter. In this sketch, the calibration of LDR values to */ #include int light = 0; //LDR readings taken and stored at pin A0. int lightCal = 0; //creating variable to store calibrated LUX values values and be called later in the loop. int LEDPIN_1 = 27; //LED pins used to react to light value differences. int LEDPIN_2 = 14; //LDR Calibration Parameters #define SNS_LIGHT_PIN 0 int sns_light_raw = 0; // the raw light value is taken from the input pin of the LDR float SNS_LIGHT_SLOPE = 0; //variable to store value relating to (assumed) linear relationship between LUX and Ohmsreadings float SNS_LIGHT_OFFSET = 0; int light_sensor_mean(int sensor_pin, int iterations=10) { //Creating an initial reading to measure against iterations. int reading = 0; Serial.println("Calculationg mean of readings... "); Serial.println("\nReading raw value..."); Serial.print("Iterations: "); Serial.println(iterations); int temporary_value = 0; //temporary value collected of raw light reading. for (int i=0; i 1000 && light < 2000) { //medium amount of light to show one LED at a time). Serial.println("moderate light quantity, quite cloudy"); digitalWrite(LEDPIN_1, HIGH); digitalWrite(LEDPIN_2,LOW); } else { // both LEDs turn on when the surroundings are dark. Serial.println("It very dark, extremely overcast or night time"); digitalWrite(LEDPIN_1, HIGH); digitalWrite(LEDPIN_2, HIGH); } delay(750); //750ms delay between sensor readings. }