/* Use a photoresistor to write characters via Serial Port More info and circuit schematic: http://www.ardumotive.com/how-to-use-a-photoresistor-en.html Dev: Michalis Vasilakis // Date: 8/6/2015 // www.ardumotive.com Changed 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 SoftwareSerial mySerial(A0, A1); // RX, TX //Variables int value; // Store value from photoresistor (0-1023) int ledState = LOW; // ledState used to set the LED void setup(){ pinMode(ledPin, OUTPUT); // Set lepPin - 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 Serial.write(43); } else{ digitalWrite(ledPin, HIGH); //Turn led on Serial.write(44); } delay(500); //Small delay }