Advanced menu system with rotary encoder for Arduino/STM32

  Рет қаралды 46,964

Curious Scientist

Curious Scientist

Күн бұрын

In this video I show you my improved menu system for Arduino/STM32. The code works on both microcontroller thanks to the STM32duino. By using a rotary encoder and a button, we can navigate on the display (20x4 LCD) and select a menu, then modify the value of a variable based on the selected menu. This will be useful for my future projects where I need to set up different target values and perform something based on the values. The 20x4 LCD allows us more freedom as the 16x2 LCD.
Please don't forget to subscribe!
Source code and schematics: curiousscientist.tech/blog/20...
If you want to support my work, please consider buying the parts using my affiliate links:
curiousscientist.tech/tools

Пікірлер: 75
@hosseinashkboos5188
@hosseinashkboos5188 2 жыл бұрын
You are very good with your clear programming and comments. Thank you very much. Many blessings to you.
@CuriousScientist
@CuriousScientist 2 жыл бұрын
Thank you! I am trying to explain my codes as detailed as possible. Not only because other people can understand it more, but I also learn a lot by it.
@hosseinashkboos5188
@hosseinashkboos5188 2 жыл бұрын
@@CuriousScientist I can see that, as many of the experts don't explain in the way new commers to programming can understsnd. Thanks again.
@yosemitesam8791
@yosemitesam8791 3 жыл бұрын
Just purchased an I2C LCD display so I can duplicate your setup. Many thanks!
@CuriousScientist
@CuriousScientist 3 жыл бұрын
I hope your project will be successful!
@apbosh1
@apbosh1 Жыл бұрын
This is just what I'm looking for. Need to first set a few values , then run the operations with those set values. Perfect. I might go a step further and save them in eeprom. Thanks 😊
@CuriousScientist
@CuriousScientist Жыл бұрын
Enjoy! Happy to hear that it is useful to you!
@apbosh1
@apbosh1 Жыл бұрын
@@CuriousScientist yes. I've seen more advanced code for menu systems but that's no good to me. I like this approach for what I'm doing, I can follow it properly.
@corbymodelboatclub
@corbymodelboatclub 10 ай бұрын
Very interesting with nice clear instructions and programme .
@CuriousScientist
@CuriousScientist 10 ай бұрын
Thank you!
@malithjayalath6417
@malithjayalath6417 Жыл бұрын
Thank you very much learnt a lot
@CuriousScientist
@CuriousScientist Жыл бұрын
Great to hear that! Cheers!
@paulpixzy5297
@paulpixzy5297 Жыл бұрын
Thanks for this it inspired me duo
@CuriousScientist
@CuriousScientist Жыл бұрын
Glad to hear it! Cheers!
@skelethornbro
@skelethornbro Жыл бұрын
Hi. Thanks for this great video. How to make the cursor blink instead of X when we select the menu? Or is it possible to highlight the selected menu?.
@CuriousScientist
@CuriousScientist Жыл бұрын
Hi! Both are a bit more complicated. Blinking the cursor would mean that you would need to draw and erase a cursor with some timing. It is doable, but in my opinion, it doesn't worth the mess. Highlighting is also possible. I don't exactly know if this specific display and the corresponding libraries can do it, but I did it with other displays in the following way: The unselected item is printed with the default letter colour (in this case, black), then when I move on the item, first I draw a black rectangle over the area of the text, then I print a white text over this rectangle. Then, when I unselect/navigate away from the item, print a white rectangle over the previous area and reprint the original text in black. It is a lot of coding and you have to carefully keep track of the position on the menu, you have to implement navigation in both directions...etc. I implemented a very similar strategy for my soldering station: kzfaq.info/get/bejne/b96RlpqS2Muop6c.html
@MarsMan2482
@MarsMan2482 3 жыл бұрын
I am going to be using something like this for a home made raspi camera
@CuriousScientist
@CuriousScientist 3 жыл бұрын
Nice! Good luck with the project!
@ben64257
@ben64257 2 жыл бұрын
what is that support for the LCD? looks cool
@CuriousScientist
@CuriousScientist 2 жыл бұрын
It is a "makers third hand" from Omnifixo. Definitely check them out, they recently released a new version (M4.2).
@tybozo
@tybozo 8 ай бұрын
thanks, nice tutorial but can you go over why and how you added capacitors to the rotary encoder. does that has to do with debouncing?
@CuriousScientist
@CuriousScientist 8 ай бұрын
Hi! I soldered them to the circuit. And yes, it has something to do with the debouncing. The internet is full of literature on debouncing, use the Google.
@yuriselektro2236
@yuriselektro2236 3 жыл бұрын
👍
@CuriousScientist
@CuriousScientist 3 жыл бұрын
Cheers!
@liamferro7123
@liamferro7123 Жыл бұрын
Good job! Helpfull video but what should i change if i use stm32cubeide to run it?
@CuriousScientist
@CuriousScientist Жыл бұрын
Thank you. Basically the whole code has to be changed. This is written for Arduino. CubeIDE uses a different framework (HAL) and has a totally different way of dealing with the things.
@juliusvalentinas
@juliusvalentinas 2 жыл бұрын
How do I use the chosen values stored? How to make it do something except show values on LCD?
@CuriousScientist
@CuriousScientist 2 жыл бұрын
It depends on what you want to do.
@gsuresh2u
@gsuresh2u 2 жыл бұрын
Hi, is there any updated version than this? I am using black pill
@CuriousScientist
@CuriousScientist 2 жыл бұрын
Hi! What do you mean by updated version?
@philippekheprisante1312
@philippekheprisante1312 11 ай бұрын
Hello, looks great but I think that for me, something is missing a menu entry to save and exit ( validate entries and pass values to main program) How can you do that (Sorry, I am an arduino beginner)
@CuriousScientist
@CuriousScientist 11 ай бұрын
Hi! Check my newer videos. I have many videos where I built menu systems and I implemented similar things that you require. For example, my reflow hot plate project definitely has this feature. Or the 10-channel temperature logger project.
@ioTPro
@ioTPro Жыл бұрын
Very nice tutorial. Can I use this code on STM8S development board using Arduino IDE?
@robdavidowitz6428
@robdavidowitz6428 Жыл бұрын
This is an excellent tutorial and would be absolutely perfect if I got it to work. On an Arduino UNO, 16*2 LCD, I am trying to achieve working with a rotary encoder with built in switch but absolutely nothing that I do can get the Menu > to change to X Can I please send you my circuit diagram and sketch for you to have a look at and see where I am going wrong?
@CuriousScientist
@CuriousScientist Жыл бұрын
Hi! The tutorial has nothing wrong as you can see it in the video. I published the same (or further improved and tested) code and schematics on my page. They should work perfectly if you followed my tutorial well. I am sorry but I don't have the free time to accept such assignments for free. However, you can hire me and then we can consult about the issues. Email address is on my website.
@merelbrouwer9804
@merelbrouwer9804 2 жыл бұрын
Hi there, thanks alot for the explanation and code. I'm working on a school project and i need to make a menu to hold 5 different codes. It also doesn't use a rotary encoder but a slide potmeter. I'm very new to coding in general and was wondering if you could help me with some stuff?
@CuriousScientist
@CuriousScientist 2 жыл бұрын
Hi and you're welcome! I can help with advices, but not for free. I am not a free support service.
@merelbrouwer9804
@merelbrouwer9804 2 жыл бұрын
@@CuriousScientistalright, fair enough. What is your email? That way communicating is somewhat easier
@CuriousScientist
@CuriousScientist 2 жыл бұрын
You can find my mail address on my website.
@merelbrouwer9804
@merelbrouwer9804 2 жыл бұрын
@@CuriousScientist Thanks, just sent you an email.
@Neverwite
@Neverwite Жыл бұрын
The lcd holders are like "⊙-⊙"
@CuriousScientist
@CuriousScientist Жыл бұрын
Look up Omnifixo, they are great stuff.
@ramakantpendke5033
@ramakantpendke5033 2 жыл бұрын
Hey I want to add submenus of string... Is it possible with this code ?
@CuriousScientist
@CuriousScientist 2 жыл бұрын
Hi! Well, if you know how to do it, yes, everything is possible. Probably a copy-paste is not enough. :)
@ramakantpendke5033
@ramakantpendke5033 2 жыл бұрын
Sure brother... I will try my best👍☺️
@viktorhugo8252
@viktorhugo8252 11 ай бұрын
Can this fit for 10 variables / Menü 1-10 and scaling up and down the rows? 4 variables are not so much. I thing the values have to save in 1 EEPROM byte if you leave the configuration.
@CuriousScientist
@CuriousScientist 11 ай бұрын
Yes, sure, you can fit even more variables. This is just an example that can be expanded into more complex stuff.
@viktorhugo8252
@viktorhugo8252 11 ай бұрын
@@CuriousScientist , how can you scroll through the menus if you have 10 and only 4 rows? Did you display 4 rows of 10 for the variables and change the sites 1-4 , 5-8 and 9-10 ? Please explain the possibility.
@CuriousScientist
@CuriousScientist 11 ай бұрын
Yes, I would display the first four items and then the next encoder click would shift out the first row and shift in the fifth. So the display would show 2-3-4-5 lines. And so on...
@viktorhugo8252
@viktorhugo8252 11 ай бұрын
@@CuriousScientist , is this in the related code?
@CuriousScientist
@CuriousScientist 11 ай бұрын
Download the code and see it for yourself. The code is free.
@ipadize
@ipadize 2 жыл бұрын
how many menu pages can i have? i guess basically unlimited but i want to make sure
@CuriousScientist
@CuriousScientist 2 жыл бұрын
As much as the memory of your chosen microcontroller allows. You would probably not run out of memory easily.
@ipadize
@ipadize 2 жыл бұрын
@@CuriousScientist thanks
@sam95N
@sam95N 6 ай бұрын
Bonjour Monsieur. J'ai utilisé et adapté votre code pour réaliser une télécommande à distance avec un module nrf24l01. J'arrive bien à faire varier à distance mes les. Par co tre j'aimerais que le changement d'État ou de luminosité ne soit pas instantané mais se valide uniquement quand on sort du 'menu de réglage'. En gros que la valeur ON, OFF, Blink, ou PWM ne soit prise en compte que quand on retourne avec un curseur flèche. Pourriez vous m'orienter car je suis débutant et ne trouve pas comment résoudre ce problème. Merci Samuel
@CuriousScientist
@CuriousScientist 6 ай бұрын
Hi, Please use English.
@sam95N
@sam95N 6 ай бұрын
@@CuriousScientist sorry you Can delete my comment it is a mistake. I was writing a comment on another video and youtube automatically switched to your vidéo just before I sent my comment. Thanks for your tuto
@himanshusharma-jt9xf
@himanshusharma-jt9xf Ай бұрын
please share the LCD iic library
@CuriousScientist
@CuriousScientist Ай бұрын
Hi! Download it from the library manager.
@himanshusharma-jt9xf
@himanshusharma-jt9xf Ай бұрын
@@CuriousScientist there are many libraries. I have tried them but, receiving errors. please name the library for display. it also showing error for pushButton in inturrupt.
@CuriousScientist
@CuriousScientist Ай бұрын
This is the github link for the library if I remember correctly: github.com/johnrickman/LiquidCrystal_I2C I don't know what kind of error you get, so I cannot advise on that issue....
@coryvandergrift4079
@coryvandergrift4079 3 жыл бұрын
Link to source code is broken, otherwise great video!
@CuriousScientist
@CuriousScientist 3 жыл бұрын
Thanks for letting me know it! I fixed the link, I just did a typo. It should work now.
@Mr.Leeroy
@Mr.Leeroy 3 жыл бұрын
I know it works, but it is a bad practice to have unnecessary code in interrupt routines. You should not have handled program logic inside, but simply detect states, set flags. And it would solve the issue with updating cursor, as you could still have had old position, erase it first, then based on a flag set the new one.
@CuriousScientist
@CuriousScientist 3 жыл бұрын
All I did in the interrupts are increasing/decreasing a value and changing a boolean's state. Where do you exactly see the bad practice? How would you implement it correctly then?
@Mr.Leeroy
@Mr.Leeroy 3 жыл бұрын
​@@CuriousScientist only detect rotation event and direction. comparisons as everything else take up mcu core time and it will bite you in a more complex project with sensitive timings. Let Ben Buxton show you how. In in your example with his lib even polling would suffice and you won't notice that interrupts are not used: github.com/buxtronix/arduino/tree/master/libraries/Rotary
@CuriousScientist
@CuriousScientist 3 жыл бұрын
Thanks, I will look this up and will try to adapt it for more complex codes. Luckily, I don't have time critical codes yet, so the technique I use works just fine. But, yes, if there's a way to improve, then let's improve!
@ishworshrestha8361
@ishworshrestha8361 Жыл бұрын
so you call this ADVANCED MENU SYSTEM??
@CuriousScientist
@CuriousScientist Жыл бұрын
Yes. Problem?
@ishworshrestha8361
@ishworshrestha8361 Жыл бұрын
@@CuriousScientist not sure how is that even a menu system........not even coming to word advance
@CuriousScientist
@CuriousScientist Жыл бұрын
I am not going to argue with you. If you don't like it, don't watch it.
@ishworshrestha8361
@ishworshrestha8361 Жыл бұрын
@@CuriousScientist oky
@alexptvz1076
@alexptvz1076 Жыл бұрын
man are you russian?
@CuriousScientist
@CuriousScientist Жыл бұрын
Nope.
Building an SZBK07-based thermostat for Peltier cooling
48:45
Curious Scientist
Рет қаралды 2 М.
Уроки Arduino. Работа с энкодером
10:55
Заметки Ардуинщика
Рет қаралды 179 М.
Дибала против вратаря Легенды
00:33
Mr. Oleynik
Рет қаралды 5 МЛН
3M❤️ #thankyou #shorts
00:16
ウエスP -Mr Uekusa- Wes-P
Рет қаралды 13 МЛН
1 or 2?🐄
00:12
Kan Andrey
Рет қаралды 46 МЛН
Best code to use with a KY-040 Rotary Encoder? Let's find out!
9:13
Arduino with I2C LCD and Rotary Encoder
16:21
John Miller
Рет қаралды 28 М.
How to use a Rotary Encoder with an Arduino - CODE EXPLAINED!
21:11
How to use rotary encoders
14:12
FriendlyWire
Рет қаралды 29 М.
PlatformIO - A True Alternative to the Arduino, MBED, and STM32 IDEs
16:10
✔ Multitask Arduino with State Machines (& Switch Debouncing)
30:42
Normal Universe - Chris Guichet
Рет қаралды 68 М.
Simple maintenance. #leddisplay #ledscreen #ledwall #ledmodule #ledinstallation
0:19
LED Screen Factory-EagerLED
Рет қаралды 25 МЛН
⚡️Супер БЫСТРАЯ Зарядка | Проверка
1:00
Tag her 🤭💞 #miniphone #smartphone #iphone #samsung #fyp
0:11
Pockify™
Рет қаралды 22 МЛН
Собери ПК и Получи 10,000₽
1:00
build monsters
Рет қаралды 2,3 МЛН