#include //LCD library LiquidCrystal lcd(2, 3, 4, 5, 6, 7); //LCD initialisation int photoResistorValue = 0; //Var to store reads from photoresistor void setup() { lcd.begin(16, 2); //LCD type definition lcd.setCursor(0, 0); lcd.print("Light: ? %"); lcd.setCursor(0, 1); lcd.print("Wunderlamp: ?"); pinMode(10, OUTPUT); // output for LED } void loop() { // read from ADC photoResistorValue = analogRead(A1); int lightPercent = 100 * photoResistorValue / 255.0; // Print how much light we have in the room String s = ""; if(lightPercent < 10) { s = " "; } lcd.setCursor(0, 0); lcd.print("Light: " + s + String(lightPercent) + "%"); // Turn the lamp on or off if (photoResistorValue < 100) { digitalWrite(10, HIGH);// LED on lcd.setCursor(0, 1); lcd.print("Wunderlamp: ON "); } else { digitalWrite(10, LOW);// LED off lcd.setCursor(0, 1); lcd.print("Wunderlamp: OFF"); } // Huge delay as LCD needs such delay(300); }