/* Based on: http://www.ardumotive.com/how-to-use-a-photoresistor-en.html Dev: Michalis Vasilakis // Date: 8/6/2015 // www.ardumotive.com Modified by Gleb, Lukasz*/ #include //Constants const int pResistor = A3; // Photoresistor pin const int ledPin = A2;// LED pin //Variables uint16_t value; // Store value from photoresistor (0-1023) int ledState = LOW; // ledState used to set the LED void setup(){ unsigned long previousMillis = 0; // will store last time LED was updated pinMode(ledPin, OUTPUT); // Set LEDPin - A2 pin as an output pinMode(pResistor, INPUT);// Set pResistor - A3 pin as an input (optional) } void loop(){ value = analogRead(pResistor); if (value > 500){ //You can change value "25" digitalWrite(ledPin, LOW); //Turn led off delay(100); digitalWrite(ledPin, HIGH); //Turn led on } else{ digitalWrite(ledPin, HIGH); //Turn led on } }