Evolution of a Blog

This blog has evolved as I have as a maker. It starts at the beginning of my journey where I began to re-tread my tires in the useful lore of micro electronics and the open-source software that can drive them. While building solutions around micro-electronics are still an occasional topic my more recent focus has been on the 3D Printing side of making.

Saturday, May 4, 2013

Simple Vertical Menu for Arduino LCD Shield

Decided that I needed a real simple menu using the buttons on the Arduino LCD Shield.   I only need a simple menu so am just using the up and down buttons with the select button for making a choice.

Here is the code.   The key working bits are shown by the below snippets.  First define the character arrays that will comprise your menu items.  They need to be no more than fifteen characters long.   Remember to terminate the list with an empty entry!

Note the use of the compile option PROGMEM which moves the menu items to program storage and saves short supply RAM.

// Enable storage of literals in program space rather than RAM
#include <avr/pgmspace.h>


   // The menu entries list needs to end with a blank entry and each item
    // can only be 15 characters long:
    //                      [               ]
    PROGMEM char* menu1[]={ "Menu 1, Item 0",
                            "Menu 1, Item 1",
                            "Menu 1, Item 2",
                            "Ascii Table   ",

Then invoke the menu as shown below:
    int selection = menuSelection(menu1);

If I find that I need more functionality I may add some to this routine later but at the moment all I need is a simple vertical menu.


  1. but...how can you get anything when an item is selected? a program, or entering the value of a variable, etc..? That's my question at this point :D

  2. I am not sure that I understand the question. When you call the menu routine with your menu structure loaded per the example as menu1:

    int selection = menuSelection(menu1);

    The number that corresponds to the users choice from the menu items is passed back as an integer from 0 to the number of items in the list less one.

  3. how i adding code, pum 1 2,3,4, setting sub menu have pump 2 setting add value, value 1-100=time X pump2 run time x. .
    main menu have all pump 1,2,3,4,5 and sub menu have pump1 setting, pump2 setting, etc,,,,,, then all pump has setting can run whitch pump have selekted or all pump (run) button.

    how adding sub menu,setting number 1-100 and calculate number=x time, pump run time x.i no understand code good yet.