I2C LCD 20x4 Change page one button.


I have been trying to find a simple code example where i can switch pagers with one button. In my project i only need 3 pages to display values.

I have a code from this thread: http://forum.arduino.cc/index.php?topic=93350.0

and that code works to switch between pages BUT my values from my sensors does not update while im displaying the diffrent pages.. Shall i throw that code in the garbage or is there anything I can add to that code to make it update my readings from sensors..??

Or does anyone here have a better code example on an 4x20 display that i can change pages with my values updating in realtime.


I am not sure what you are asking.
If you don't need to change "pages", then don't.

I Just want to switch screen at one puch on a button..

And yet there is no code.

guessing here. but you have 3 (three) 20 x 4 displays and you want to toggle between display on them with a button press?

If so, the first thing you will need are 20 x 4 displays with different (or programmable) addresses. Keeping it simple, let's say the addresses are 1 for display1, 2 for display2, and 3 for display3

then in your code you will need to create 3 lcd objects appropriately named for the display number, something like this

LiquidCrystal_I2C lcd1(I2C_ADDR, En_pin, Rw_pin, Rs_pin, D4_pin, D5_pin, D6_pin, D7_pin);
LiquidCrystal_I2C lcd2(I2C_ADDR, En_pin, Rw_pin, Rs_pin, D4_pin, D5_pin, D6_pin, D7_pin);
LiquidCrystal_I2C lcd3(I2C_ADDR, En_pin, Rw_pin, Rs_pin, D4_pin, D5_pin, D6_pin, D7_pin);

then write to the desired display based on the button counter, like

if button count = 1 then
lcd1.setCursor(0, 1);
lcd1.print("display 1.");

if button count = 2 then
lcd2.setCursor(0, 1);
lcd2.print("display 2.");

if button count = 3 then
lcd3.setCursor(0, 1);
lcd3.print("display 3.");

More elegantly, have your displays in an array with the index mapped to a button or button counter

its been my experience that these lcd's will cache the display until updated--which may be a good thing.

Your challenge will be to find 20 x 4 displays with different addresses. I've not found any, but not looked very hard. I remember doing something similar with a 20 x 4 LCD and a .96" OLED

Hope this helps.