Hello everybody, I'm here to ask a question I'm not able to solve on my own. I'm not good at programming, so it may be a silly question, but I can't find a solution. I'm building an Arduino based humidity and temperature monitoring system, with three DHT-11 sensors and a display to show readings from them. I'd like to be able to toggle LCD's backlight on with a pushbutton and have the code switch it off after a while. I can't figure out how to make Arduino do it. All I could make till now is Arduino switching backlight ON at the beginning of the code regardless of the buton being pressed or not. Here is the code I wrote, I bolded the part relative to the pushbutton. Can anyone help me, please? #include "DHT.h" // include DHT sensor library code #include // include lcd display library code LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // Initialize lcd on these pins #define DHTPIN A0 // sensor1 1 #define DHTPIN2 A1 // sensor 2 #define DHTPIN3 A2 // sensor 3 // Uncomment whatever sensor type you're using! #define DHTTYPE DHT11 // DHT 11 //#define DHTTYPE DHT22 // DHT 22 (AM2302) //#define DHTTYPE DHT21 // DHT 21 (AM2301) // Initialize DHT sensor for normal 16mhz Arduino DHT dht(DHTPIN, DHTTYPE); DHT dht2(DHTPIN2, DHTTYPE); DHT dht3(DHTPIN3, DHTTYPE); #define light_button 8 #define backlight_pin 13 int val; int state; void setup() { Serial.begin(9600); lcd.begin(16, 2); // set up the LCD's number of columns and rows: dht.begin(); // enable DHT sensors pinMode(light_button, INPUT); pinMode(backlight_pin, OUTPUT); state = 0; } void loop() { val = digitalRead(light_button); Serial.println(val); if(light_button != state){ digitalWrite (backlight_pin, HIGH); } else { digitalWrite (backlight_pin, LOW); } // READING SENSOR 1 // Reading temperature or humidity takes about 250 milliseconds! // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor) float h1 = dht.readHumidity(); float t1 = dht.readTemperature(); // Read temperature as Celsius float hi = dht.computeHeatIndex(t1, h1); // Compute heat index lcd.setCursor(5, 0); // Print values from sensor 1 on lcd lcd.print("Teca 1"); lcd.setCursor(0,1); lcd.print("Umidita': "); lcd.print(h1); lcd.print("%"); delay(3000); // Show humidity value for 3 seconds lcd.setCursor(0,1); // Switch to temperature visualization lcd.print("Temperat: "); lcd.print(t1); lcd.print("C"); delay(3000); // Show temperature value for 3 seconds // READING SENSOR 2 float h2 = dht2.readHumidity(); // Read humidity float t2 = dht2.readTemperature(); // Read temperature as Celsius float hi2 = dht.computeHeatIndex(t2, h2); // Compute heat index lcd.setCursor(5, 0); // Print values from sensor 2 on lcd lcd.print("Teca 2"); lcd.setCursor(0,1); lcd.print("Umidita': "); lcd.print(h2); lcd.print("%"); delay(3000); // Show humidity value for 3 seconds lcd.setCursor(0,1); // Switch to temperature visualization lcd.print("Temperat: "); lcd.print(t2); lcd.print("C"); delay(3000); // Show temperature value for 3 seconds // READING SENSOR 3 float h3 = dht3.readHumidity(); float t3 = dht3.readTemperature(); // Read temperature as Celsius float hi3 = dht.computeHeatIndex(t3, h3); // Compute heat index lcd.setCursor(5, 0); // Print values from sensor 3 on lcd lcd.print("Teca 3"); lcd.setCursor(0,1); lcd.print("Umidita': "); lcd.print(h3); lcd.print("%"); delay(3000); // Show humidity value for 3 seconds lcd.setCursor(0,1); // Switch to temperature visualization lcd.print("Temperat: "); lcd.print(t3); lcd.print("C"); delay(3000); // Show temperature value for 3 seconds }