Switch on LCD using sensor signal?

Hi all.
Is it possible to switch on a i2c, 20,4 LCD with an external signal from say a I/r Movement Sensor ??

Regards, Ray

Switching power on and off is no easy task. Usually the downpowered device draws current from rhe logic connections.

Do you mean swiching the power to the LCD on and off, turning the backlight on and off or blanking the display (turning the display off while leaving the power on)?

If you switch the power off and back on you will have to re-initialize the display using the begin() function. Plus the complications that @Railroader mentions. Once you turn the backlight off you will save little current by turning off power to the display. IMO not worth it.

Some libraries have functions to control the backlight.

Most libraries have a function to blank the display. Like LiquidCrystal’s display() and noDisplay() functions.

Hello
you can control the LED backlight brightness of LCD by using the unjumpered pins on the left side.
grafik

Sorry, I should have a bit clearer, I want the display to come on when activated by a sensor, example, someone knocks on my door, so a Knock sensor sends a signal to Arduino that it has picked up activity, then I want the LCD to light up and show a message, so it does look like I only need the backlight to come on and off, can you advise how to do?

Hi again.
Regarding the Vibration Sensor. I now have a sketch which gives a display on the LCD, and flashes LED’s in a Knight-rider sequence, now my question is "How can I turn this sketch on to RUN, when the sensor picks up Vibration?

The libraries for I2C displays have the functions noBacklight(), and backlight() to control the backlight. And there is also the display() and noDisplay() functions to blank and unblank the display.

There are several libraries with the name LiquidCrystal_I2C. The are not all the same and code from 1 may not run in another. Those LiquidCrystal_I2C libraries are old and most are not maintaned. The newest and absolute best library for I2C LCD with the hd44780 controller (1602, 2004) is the hd44780 library by Bill Perry. The nice thing about the hd44780 library is that it will autodetect the I2C address and the I2C backpack to LCD pin mapping. The hd44780 library is available through the IDE library manager.

Something like:
if the vibration is over a threshold
turn on backlight
turn on display
execute code
else
turn stuff off
do nothing
If you have trouble, post the code, tell us what the code does and how that differs from what you want. Post code in code tags and format the code with the IDE autoformat tool (ctrl-t or Tools, Auro Format) before posting.

Hi, I have managed to get the attached code to work, but it only runs once, until the vibration sensor is hit again, how can I keep the sketch running?

int vib_pin=A0;
int led_pin1=5;
int led_pin2=6;
int led_pin3=8;
int led_pin4=9;
int led_pin5=10;
int led_pin6=11;
int led_pin7=12;
int led_pin8=13;
int val;

void setup() {
pinMode(vib_pin,INPUT);
pinMode(led_pin1,OUTPUT);
pinMode(led_pin2,OUTPUT);
pinMode(led_pin3,OUTPUT);
pinMode(led_pin4,OUTPUT);
pinMode(led_pin5,OUTPUT);
pinMode(led_pin6,OUTPUT);
pinMode(led_pin7,OUTPUT);
pinMode(led_pin8,OUTPUT);
}
void loop() {
val=digitalRead(vib_pin); 
if(val==1)
{
digitalWrite(led_pin1,HIGH);
delay(100);   
digitalWrite(led_pin2,HIGH);
delay(100);
digitalWrite(led_pin3,HIGH);
delay(100);
digitalWrite(led_pin4,HIGH);
delay(100);
digitalWrite(led_pin5,HIGH);
delay(100);   
digitalWrite(led_pin6,HIGH);
delay(100);
digitalWrite(led_pin7,HIGH);
delay(100);
digitalWrite(led_pin8,HIGH);
delay(100);

digitalWrite(led_pin8,LOW);
delay(100);
digitalWrite(led_pin7,LOW);
delay(100);
digitalWrite(led_pin6,LOW);
delay(100);
digitalWrite(led_pin5,LOW);
delay(100);
digitalWrite(led_pin4,LOW);
delay(100);
digitalWrite(led_pin3,LOW);
delay(100);
digitalWrite(led_pin2,LOW);
delay(100);
digitalWrite(led_pin1,LOW);
delay(100);

}
}