Check-Menus.com

arduino multi level menu

by Kennedy Renner IV Published 3 years ago Updated 2 years ago
image

int menuLevel1 = 0; int menuLevel2 = 0; Assuming you have 2 levels, if you have more levels consider an array. Now you can print the screen based on the values of these two variables (use a switch statement for menuLevel1 which calls new functions, each with their own switch statement for menuLevel2.

Full Answer

How to use Arduino Uno with visuino?

Start Visuino as shown in the first picture Click on the "Tools" button on the Arduino component (Picture 1) in Visuino When the dialog appears, select "Arduino UNO" as shown on Picture 2.

How big is the compiled code for the Arduino Uno?

If I comment out the DEBUGGING lines (noting that some visual feedback would still be needed for menu navigation) the compiled code is around 1,650 bytes for the Arduino Uno, hopefully leaving plenty of room on your ATMEGA328P for the more exciting parts of your sketch! Go to Step 3 to find out how the menu system works.

What pins does the Arduino connect to the LCD?

Connect pins 2, 3, 4 and 5 of the Arduino to pins 14, 13, 12 and 11 of the LCD (These are the Data pins of the LCD)

What is the default value of MENU (0) on the LCD?

The default value of menu (0) prints on the LCD "Select Menu Option". When pressing SELECT, the LCD is cleared. The menu is being set to an unknown number, so that it doesn't print anything, and subMenu is set to 1.

image

How many pins are in a LMB162ABC?

The LMB162ABC has 16 pins. Pin 1 and 16 are numbered. Place the LCD onto the Breadboard. (You might need to solder header pins onto your LCD screen first) Place a lead from the Ground rail to pin 1 of the LCD. Connect pin 2 of the LCD to the Positive rail of the breadboard.

How to connect an LED to a negative rail?

Place the led between 2 terminal strips. Place a resistor from the Anode to another Terminal Strip. Connect pin 9 of the Arduino to the Resistor. Connect the Cathode of the LED to a negative rail.

Step 1: What You Will Need

LCD Display I2C 20X4 (if you use diferent LCD then make sure that you specify the right Columns and Rows in the Visuino component)

Step 3: Start Visuino, and Select the Arduino UNO Board Type

The Visuino: https://www.visuino.eu also needs to be installed. Download Free version or register for a Free Trial.

Step 5: In Visuino Set Components

Select "UpDownCounter1" and in the properties set Max > Value to 3 and Min > Value to 0

Step 7: Generate, Compile, and Upload the Code

In Visuino, at the bottom click on the "Build" Tab, make sure the correct port is selected, then click on the "Compile/Build and Upload" button.

Step 8: Play

If you power the Arduino module and by pressing the buttons you will be able to change the menu selection on the LCD.

Step 1: Preparation

If you haven't yet, please see my other Instructable on rotary encoder reading to find out how to set up your hardware and Arduino IDE software.

Step 2: Code

This is the code. By looking at the structure and the comments I hope you will find it easy to adapt for your specific needs!

Step 3: Operation and Conclusion

If you open the serial monitor in Arduino after uploading this sketch, and start to turn the encoder shaft, you should see the top level menu rotating through the number of sub-menus/options you have (limited using the modeMax variable).

image
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9