How to turn off/on an LCD with a button

Hello. I'd like to know how I can turn off/on an LCD with the help of a button. I want it to turn off when I press the button once and not stay off as long as I press the button continuously.

You need to detect when the button [u]becomes[/u] pressed not when it [u]is[/u] pressed

Look at the StateChangeDetection example in the IDE

DevikaSujith: Hello. I'd like to know how I can turn off/on an LCD with the help of a button. I want it to turn off when I press the button once and not stay off as long as I press the button continuously.

Do you want to turn off the tire LCD or just the back light?

What model of LCD?

The entire LCD. I'm using the 1602 screen.

Sorry to be picky, but what do you mean by turning off the entire LCD ? Are you trying to save power or is there another reason ? How much current does the LCD screen take ?

I'm working on a project. Basically, when I press a button, the LCD backlight and display turns off. When I press the button again, the LCD should turn on.

Keep in mind that if you turn the LCD itself ‘off’ by switching power to the module, then every time you turn it ‘on’, you’ll have to re-initialise it, and repopulate the display contents.

It is usually easier to simply control the backlight.

have you tried a transistor?

DevikaSujith: I'm working on a project. Basically, when I press a button, the LCD backlight and display turns off. When I press the button again, the LCD should turn on.

I am not clear where you are stuck.

For instance Do you know how to change the state of an output with successive button presses ? Do you know how to turn the LCD backlight on and off ? Do you know how to turn the power to the LCD on and off ?

In response to #7 - No, I haven’t tried a transistor. What does it do?

In response to #8 - I know how to turn on/off the backlight of the LCD. I don’t know how to do the others.

Would turning the backlight off be good enough ?

DevikaSujith: In response to #7 - No, I haven't tried a transistor. What does it do?

In response to #8 - I know how to turn on/off the backlight of the LCD. I don't know how to do the others.

It is a serial LCD isn't it? Something you should have mentioned maybe?

There is a reason people asking if turning the backlight off would be good enough. From a random datasheet: the LCD itself draws 2mA, the backlight draws 150mA current. Yet you wouldn't even answer the question.

We have not seen any code, any circuit diagrams from your project. Presumably we don't even now the exact model of your LCD display.