Arduino Settings Menu

by taste_the_code in Circuits > Arduino

12583 Views, 48 Favorites, 0 Comments

Arduino Settings Menu

Easy and Simple Arduino Settings Menu - How to

When working on a project with an LCD screen, we often need to set a certain amount of parameters and have the ability to adjust them later on with the project operation.

Since in the day-to-day operation of the project, there will be one main screen for the display of information, these extra parameters are hidden behind a settings menu that we can then access to adjust the parameters.

In this Instructable, I'm going over the process of creating such a menu that we can interact with by using a rotary encoder.

This post is sponsored by PCBWay. Get your custom PCBs, SMD stencils, or assembly services professionally done for cheap in less than 24 hours.PCBWay also offers sponsorships for students and hobbyists where you can get your projects built for free.

This Instructable and video is part of my pellet burner project series and you can find the rest of the videos in the dedicated playlist on my YouTube channel.

https://www.youtube.com/playlist?list=PLfwpK3RIxFR...

Supplies

Arduino Modules Wiring

VID_20210812_065852.00_09_33_26.Still008.jpg
VID_20210812_065852.00_03_05_06.Still003.jpg

To display a menu, the only required components are the LCD screen and the rotary encoder. In this example, I also have a DS1302 real-time clock module attached so I can demonstrate how all of the modules can be integrated and work with each other.

The LCD is connected to the Arduino Nano through I2C on pins A4 and A5, the rotary encoder uses pins D3 (interrupt pin 3) and D4 for the rotational input and D2 (interrupt pin 2) for the onboard switch. Additionally, a small 100nF ceramic capacitor is connected between D2 and GND for debouncing purposes on the encoder switch.

The RTC module is connected using pins D7, D8, and D9 by using the so-called 3 wire interface.

I have separate Instructables for each of them that you can find below:

DS1302 RTC Module - https://www.instructables.com/Real-Time-Clock-Modu...

LCD Module - https://www.instructables.com/Connect-LCDs-With-No...

Rotary Encoder - https://www.instructables.com/How-to-Use-Rotary-En...

Menu Screens

VID_20210812_065852.00_00_12_22.Still002.jpg
VID_20210812_065852.00_03_50_09.Still004.jpg
VID_20210812_065852.00_16_28_05.Still007.jpg

Each of the parameters that we need to control will have its own screen where we will display the parameter name, its current value, and the units that that parameter has.

To keep the example simple, all of the parameters are defined as integers and there is no validation in terms of minimum and maximum values, but once you get hold of the basic example, those can be easily added.

The navigation between each of the menus is done by pressing on the rotary encoder switch and by turning the encoder, the value is either increased or decreased for the current parameter.

Arduino Code

VID_20210812_065852.00_06_06_21.Still005.jpg
VID_20210812_065852.00_08_55_12.Still006.jpg

You can check the attached video for the full explanation of the code but basically, we have attached an interrupt call to the switch of the rotary encoder and that is called each time that we press the switch. This call increments the variable that we have for keeping track of the current switch and tells the main loop function that it now needs to update the screen with the menu.

Inside the loop function, we also check if 4 seconds have passed since the last switch press and if that is true, we return the display to the original screen that we had before.

The rest of the code for the RTC module, rotary encoder, and LCD screen are explained separately in the appropriate Instructables.

The full code used in the example is attached here.

Next Steps

VID_20210812_065852.00_00_11_04.Still001.jpg

With the basic menu example out of the way, we can expand on this code by adding default values, validation, and even step definitions for each of the parameters and I'll provide that code in the future with the rest of the pellet burner project.

If you are interested in seeing that, then be sure to subscribe to my YouTube channel, and in the meantime, you can check some of my other Instructables.

Cheers and thanks for reading.