Hello, my name is Dylon J. Today Iwas playing around with my lcd and arduino. I wanted to go to a new page on the lcd. So if I have "hello world" on it I want to press a button to go to a "page" or in other words display test. But if I push it again, I want to exit out to hello world. Can you guys help? I a noob at arduino coding. Thanks!
First look up button debounce. When the button is pushed will open and close several times before it settles on the new level. Once the button is debounced you can count presses and, using select case statements, choose what is sent to the display.
you can count presses
That would require looking at the state change detection example.
the debounce is not an issue because the arduino has a 250 millisecond delay on the button. Also I will try the state change detection and tell if it works out. Thanks you!
using the delay isn't your best option. The delay basically "pauses" your sketch, so if in that time you would press any other button, or need anything else to happen, then it won't work as you planned.
You can take a look at the BlinkWithoutDelay tutorial to see a better way to achieve a "delay effect" without using the delay() function (so you can still do something else in that time, like printing to your lcd, for example).
about the menu...
here are a couple of pages that might give you some ideas,
the MenuLibrary:
http://playground.arduino.cc/Code/Menu
and a page i remembered reading about menus:
and i am sure if you search in google you will find many more...
Portal:
the debounce is not an issue because the arduino has a 250 millisecond delay on the button. Also I will try the state change detection and tell if it works out. Thanks you!
A quarter of a second, eh? Well the buttons might seem a tad sluggish.
See also here:
http://playground.arduino.cc//Main/InterfacingWithHardware#ui
Of course i suggest M2tklib, which is the one i wrote
Some benefits for M2tklib:
- Supports LiquidCrystal and fm's NewLiquidCrystal Lib
- Also supports some GLCD libs, so that the code can be easily taken over to GLCDs
- LCD over serial simulation, that means, the menues are displayed on the serial monitor and buttons can be simulated via input from serial monitor. As a result, for the testing of M2tklib you just need a plain Arduino Board (without buttons and wthout LCD).
- Button debounce is part of M2tklib. Also supports rotary incremental encoder. Examples for analog buttons are available.
http://code.google.com/p/m2tklib/
Oliver