Arduino LCD 16x2 interactive menu + rotary encoder WITH CODE

preview_player
Показать описание
All of the libraries i found for creating menu's on arduino were to difficult and i didnt understand them.

So this is my effort to create a menu system for Arduino combined with an LCD. My LCD is a i2c version.

The menu allows unlimited levels, and allows you to change numeric values but also text values defined in an array. The menu works with a rotary encoder that acts differently based upon single and double clicks. For example double click is return to 1st level.

Values can be changed to a maximum and minimum. You can also set the amount of increments.

The code is very rough, and the method used im sure can be way more efficient. It uses up 50% of the resources on an Arduino UNO.

I tried to comment as much of the code. Please note that this code also writes to the serial monitor. You DONT need an LCD to run this. The serial monitor i used for debugging purposes.

The download package includes all the libraries and the code.

DOWNLOAD LINK:

TODO
Store the values selected in the menu within the EEPROM. But thats planned for later.

WIRING
LCD i2c, pin A4 and A5
Rotary button, pin 8
Rotary DT, pin 2
Rotary CLK, pin 4
You can change these pins in the code.
Рекомендации по теме
Комментарии
Автор

Just what I was looking for, but new to coding. Im lost at the menu and value arrays. Im trying to figure out how to modify this. I need a menu ike the following. (Set time > (options)Set HR || Set Min, Set Feed Time > (Options)Set HR, Set Feed Amount> (options)1 cup, 1.5 cup, Set Sound> (options) On || OFF. Could you expalin how I would go about this. The Set time would call other functions to change the time. Thank You

yukonschannel
Автор

Thanks for this Video, I have struggled to find a menu + encoder + I2C LCD demo. Many thanks my friend.

MattBaker
Автор

Hi,
Your menu is simple and helpful but please how do I save/access values entered (like that of rotation) to be used for speed selection or whatever. Thanks

dramusar.
Автор

I just want to use the rotation menu and it's submenu which part of the code should I exclude, please help I am not getting success I have been trying for a month now

DwipayanGupta
Автор

I have a 20, 4 LCD display, i change it in the code, but only 2 options on a "side" how can i change it?

Philip_lip
Автор

Hi, did you add the homescreen and did you finish your watch winder? I am trying to build my own and I would appreciate it if I could see the whole code. You helped me a lot so far.

gerasimos
Автор

thanks for your code! super cool !
but, i don't find a solution to use the type 2 value.
You have this thing ( 2 - type, starting value in options array, lowest value options array, max value options array), but where i can find the value ?
Like 0 = Left , 1=Right, 2=MIX.

i think it's an idiot question but i have search a lot .... :/

PsykocatOfficial
Автор

Is it possible to replace the 16x2 line LCD for a 40x4 LCD? Will that break the code?

Also in the code there's this:

"3", "256Active", "2__Item2.2", "2__Item2.3", // Layer 2

So root menu layer 2 has 3 items. All start with '2' so they refer to their own layer, correct?

The first item has number '256'. The code explains that the second number refers to the value in the array, correct? This is the array, and to my basic knowledge it starts at zero. So the one with the X in front of it is the value it will read?

//
0 1, 11, 25, 50, 1450, //0-4 WATCH1
1 2, 2, 0, 2, //5-8
2 1, 600, 25, 75, 600, //9-13

3 1, 11, 25, 50, 1450, //14-18 WATCH2
4 2, 2, 0, 2, //19-22
5 X 1, 600, 25, 75, 600, //23-27 <-- this is 5?

1, 11, 25, 50, 1450, //28-32 WATCH3.

etc
//

If so, then what is the 6 referring to?

Thanks a bundle, tried a lot of waaay too complex menu's to just set some values. This looks awesome!

snewpers
Автор

Hi, I apreciated Your Video Good Job, can you inserted Skema from this Video? I need to understand about this Video

vivaldy
Автор

the code is good, but I am totally stuck: I wanted add menu items, but when I try to add a value that is in the array on a position bigger than 9, everything breaks. For example: 113 - because it has to point to position 13 in the values array. It only accepts 1 digit. How can I change it to make it run 2 digit numbers?! And how can I work with the values set by the user? Can i "save" them to variables somewhere?

NeuArtChan
Автор

i'm a bit stuck with my idea. I want to use only two buttons for choosing list options.
the first button increases index that each part of the list has, and the 2nd just selects it.
e.g. index 1 is tomatoes, index 2 cucumbers index 3 pepper. while pressing this button i don't want to repeat myself and just go through the loop from 1 to 3. Thus the 2nd button checks the index and confirms my choice. i know its easy to do but omg)

oOcitizenOo
Автор

i wish you can teach us step by step..

youtubefun_
Автор

Great code, but I'm Need help changing it to make it work with machine I'm using, if you could help me that be great thanks

EverythingCustomBuild
Автор

Friend, excellent code, but I want to use the menu to handle two variables and when I see your code, both speed and rotation have the same variable, as I can save the data but in different variables.
I appreciate your prompt reply

santiagomedina
Автор

Hello, how can i change the code to get all Lines on one page? I changed a lot of in the code But i still have the Problem that, you See the First line from Layer 1, in Layer 0.
Do you know Where i can solve that Problem in the code?

oualidbensaddik
Автор

How do i put in my code into a menu for example:

When i turn on my arduino i go to the menu Temperature and there i will have my code for checking the temp with my thermistor.

Really nice code but i cant put my code into a menu

verylongchannelhandle
Автор

Espero este programa lo puedas explicar paso paso

rupertoespinozaolivares
Автор

If not working!!
Change Rotary Encoder section in header to this code :

// ROTARY ENCODER
long oldPosition = 0;
int encoderDTpin = 6;
int encoderCLKpin = 7;
#define RTRY_ENC_CLK 7
#define RTRY_ENC_DT 6
Encoder encoder(RTRY_ENC_CLK, RTRY_ENC_DT);
void onSwitch();
void onRotate();
Encoder myEnc(encoderDTpin, encoderCLKpin);
int buttonPin = 8;
OneButton button0(buttonPin, true);

DT=6
CLK=7
SW=8

😀

rolandpozsonyi