LCD Display switch pages based on conditions

Hey,
I am practicing with some sensors. I got a GPS and a DHT22 sensor connected to my Mega board and their data is printed on an I2C 20X4 LCD. I want to switch what data is displayed by pressing a button so I guess I have to utilize a flip flop and an if-else node but I cant find a way to swtich what data goes to each line of the LCD. It is very simple to switch what data goes to one line but when it comes to four I have no idea. This is my program( I havnt programed the button yet):

Sounds like you are over-thinking the problem. If you know how to switch text on one line, you know how to do it for all 4…just repeat what you did on the 1st line for the other lines. You will need one if-else node for each line of data you want to switch. If all lines change at the same time, all the if-else-COND pins can link to the same flip-flop.

If you wanted a single-node solution, you could create your own node, but it would probably just be a wrapper with 4 if-else nodes inside. It would only save you 3 pins for COND since the one COND on your wrapper could link to COND pins on all 4 if-else nodes you are wrapping. It could clean up your main patch quite a bit if you also included the LCD nodes in your wrapper. This might be a good idea for your specific program, but it is not a very good generic solution since the next person might want to select between 3 sets of inputs instead of only 2 sets. You could use variadic pins to allow this, but it gets a little tricky since you need dummy pins to track which line your are processing within your node so you can pass the correct ROW to print-at. It gets even more complicated if also want to be able to change number of rows (XOD doesn’t currently allow multi-dimensional variadics to let you specify number of rows and number of input sets).

FYI: if you did want to select between 3 or more sets of inputs, you could cascade if-else nodes, but nth-input node would probably be a better solution. You would probably want to use a count node instead of flip-flop to cycle between the input sets (which means you need a way to reset count after you go beyond the last set of inputs; count.OUT > greater > defer > count.RST would be one solution).

1 Like