/* 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, Marjo, Perttu, Lukasz*/ #include //Constants const int pResistor = A3; // Photoresistor at Arduino analog pin A0 const int ledPin = LED_BUILTIN;// the number of the LED pin //Variables int 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 - 9 pin as an output pinMode(pResistor, INPUT);// Set pResistor - A0 pin as an input (optional) } void loop(){ value = analogRead(pResistor); if (value > 25){ //You can change value "25" digitalWrite(ledPin, LOW); //Turn led off } else{ digitalWrite(ledPin, HIGH); //Turn led on } delay(500); //Small delay }