Prueba a usar el lcd conectandola mediante I2C, usando una salida y un mosfet pueder cortar la tension de alimentacion del lcd o directamente como lo estas haciendo con un interruptor.
El codigo de ejemplo
/*
LCD PCF8574
---------------
4 10
6 9
11 4
12 5
13 6
14 7
LCD PINES
=====================
1 GND
2 VCC
3 CONTRASTE
5 RW(GND)
15 +LED
16 -LED
*/
// include the library code:
#include <Wire.h>
#include <PCFCrystal.h>
byte buffer = 0;
// initialize the library with the numbers of the interface pins
// rs, en, d0, d1, d2, d3, address, buffer
// 4 bits
PCFCrystal lcd(B00100000, B00010000, B00000001, B00000010, B00000100, B00001000, 0x20, &buffer);
// 8 bits
//PCFCrystal lcd(B00100000, B00010000, B10000000, B01000000, B00100000, B00010000, B00000001, B00000010, B00000100, B00001000, 0x21, 0x20, &data, &buffer);
void setup() {
Wire.begin();
lcd.begin(16, 2);
}
long counter = 0;
void loop() {
counter++;
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 0);
// print the number of seconds since reset:
lcd.print("Contador");
lcd.print(counter);
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print("Contador");
lcd.print(counter+1);
delay(1000);
}
Esquema
