how to sleep a 16x2 lcd connected to arduino and wake up when we press a button?
Do you want to turn off the backlight, clear the screen, both or something else ?
What type of LCD do you have ?
16x2 lcd 5v operated 1602. to reduce the power consumption, it has to turn off the backlight and clear the screen...
Can you please post the code that you are using, perhaps just an example of writing text to the LCD, and a link to the actual device. Do you have anything in the code that explicitly turns the backlight on or have you got it hard wired to turn it on ?
LCD watches run for years on a tiny battery. But if you hold down the light button, the battery might be depleted in a hour. The backlight is the main power hog. Depending on the LCD you might be able to connect the backlight control pin to an Arduino PWM pin or you may need a transistor to switch the current.
#define BUTTONPIN 2 //Pin 2 is held high with 10kohm resistor, the button connects it to ground when pressed
#include<LiquidCrystal.h>
#include<avr/sleep.h>
LiquidCrystal lcd(10,7,3,4,5,6);
void setup() {
pinMode(BUTTONPIN, INPUT);
}
void wakeUpNow() {
//code to run immediately after wakeup
//Purely optional
//BTW, timer related things don't work here(like serial and millis())
}
void goToSleep() {
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_enable();
attachInterrupt(0, wakeUpNow, LOW);
sleep_mode();
sleep_disable(); // first thing after waking from sleep:
detachInterrupt(0);
}
void loop(){
goToSleep();
{lcd.clear();lcd.begin(0,0);lcd.print("hello");
delay(10000);
}
}