Adafruit 20x4 LCD - Creating a menu


I am relatively new to Arduino and I am currently working on a project that consists of an Aruduino Mega, 3 buttons (Left, Right and Confirm), Adafruit 20x4 RGB LCD and Adafruit LEDs.

What I want to achieve is to be able to have a menu on the LCD screen - consisting of a main menu, with two options, a secondary menu, with 13 options, and finally an action to occur (LED’s light up) when an option in the second menu is selected.

So far I have a number of codes to illuminate the LEDs in order, which is working fine, and I have been able to print to the LCD screen, however I am unsure how to create a menu that recognises which menu/submenu had been pressed to correspond to the right action.

If anyone could help it would be much appreciated.

Attached are the codes I am currently using for the LCD and for the Adafruit Neopixel LED’s


LCD_Menu_Drft.ino (1.46 KB)

A_Major_Scale.ino (1.2 KB)

You should combine your two sketches into one.

In the programming forum, there is a sticky thread near the top of page 1 with a GREAT methodology for writing a sketch. It's an easy read and I think it would help you out.

I looked at your code and it looks like you are going in the right direction! There might be better ways to debounce your buttons than the delay statement. One way is to add a small capacitor to the button. Another way is to toggle a global variable and only look for the confirm button at the appropriate time. Or to only update the screen when something changes instead of every cycle. Etc.