arduino encoder library

 


 
Today we are going to use an Arduino and a rotary encoder to build a simple menu on a Nokia 5110 LCD display. Lets get started, Hello guys. I am Nick and welcome to educ8s.tv a channel that is all about DIY electronics projects with Arduino, Raspberry, Pi, ESP8266 and other popular boards. Subscribe to the channel. Now, if you dont want to miss any future videos. In this video, we are going learn how to build our own menu for the popular Nokia 5110 LCD display in order to make our projects more user friendly and more capable.. We have built a similar project in the past, but a lot of the viewers of the channel suggested that I should prepare another video on this subject.. This time we are going to use a rotary encoder instead of push buttons.. Also the menu we are going to build today has more items to choose. From. Lets watch it in action.. This is the project we are going to build. In the display. A simple menu appears and with the help of the rotary encoder, I can navigate up or down and select a menu item by pressing the rotary encoder button.. The menu has 6 items and we can scroll down or up the menu and the items on the display will change. Accordingly. Lets select the first option.. As you can see, a new a UI screen is displayed and by rotating the rotary encoder shaft, we can change the contrast of the display.

. If we press the rotary encoder button again, we go back to the main UI screen.. The second menu item offers a similar functionality. It modifies the volume variable.. If we now select the third menu item and press the button, we can change the language value.. I have not implemented this functionality. This is just a demo project.. A similar functionality is attached to the 4th menu item, which is called difficulty.. We can disable the backlight of the display if we wish, by selecting the 5th menu item, or we can reset everything to its default value with the 6th menu item.. Of course, you can modify it to build your own, more complex menus. If you wish. Lets now see how to build this project.. The parts needed in order to build this project are the following: An Arduino Uno or any other compatible board. A Nokia 5110 LCD display A rotary encoder, A small breadboard, Some wires. The cost of the project is very low. It is less than 10.. You can find links for all the parts I use in. The description of the video below. Lets now connect all the parts together. Before building this project. If you havent used a rotary encoder in the past, I encourage you to watch the tutorial. I have prepared about rotary encoders.. It will help you understand how rotary encoders work and you are going to gain some experience with them. Click on the card here. If you want to watch it now.

, I have placed the display on a small breadboard like this. Lets. First connect the display., The first pin of the display, which is Reset, goes to digital pin, 3 of the Arduino Uno. The second pin goes to digital pin 4. The third pin goes to digital pin 5, the fourth pin to digital pin 11 and the fifth pin to digital pin 13.. The next pin is Vcc.. We connect Vcc to the positive rail of the breadboard and the breadboard positive rail to the 3.3V output of the Arduino.. The next pin is Backlight for the display., Since we want to control it via the software. We connect it to digital pin 7.. The last pin is GND.: We connect GND to the negative rail of the breadboard and the negative rail of the breadboard to Arduino GND.. Now all we have to do is to connect the rotary encoder.. The first pin is GND and we connect it to negative rail of the breadboard.. The next pin is Vcc and we connect it to the positive rail of the breadboard.. The next pin is SW and we connect it to Analog Pin 2.. The next pin is named DT and we connect it to Analog Pin 1.. Lastly, the pin CLK is connected to Analog Pin 0.. You can find the schematic diagram of this project in the description of the video below.. Now we are ready to power up the project.. As you can see, the project is working, fine and the menu is working.

As expected. Great lets now see the software of the project.. The code of the project is complex, but I will do my best to explain. It., You will get a basic understanding of how the code works, but if you want to fully understand it, you have to make your own menu and see exactly how it works. Lets start.. In this project we use 4 libraries.. We use two libraries for the display and two for the rotary encoder.. You can find links for all the libraries in the description of the video below. At first, we are going to take a look at the drawMenu function.. This function is responsible for drawing the Menu on the display.. This function is called every few milliseconds, so if there is a change on the menu, this function is responsible for updating the menu on the screen.. There are also 3 very important global variables. The variable page, the variable menuitem and variable frame., The variable page remembers, which UI screen is displayed on the screen.. So if the page variable is 1, we are in the main UI screen and if the variable is 2, we are in the secondary UI screen where we set the value on a variable.. The menu item remembers the selected menu item.. So if its value is 1, the first menu item is selected, so the drawMenu function must draw this menu item as black with white letters.. If the menu item is 2, the second menu item is selected and so on.

. The frame variable remembers, which part of the menu is displayed on the screen. Since the menu we have created contains 6 items, and we can only display 3 of them at a time. We need to know which items are displayed on the screen.. The frame variable tells us exactly this.. If the frame variable has the value of 1, we display the first three menu items. If it is 2, we display items 234 and so on.. I tried to make the code as easy as possible to modify so I have created some global variables that hold the names for the menu items.. This way you can create your own menus easily without searching in code.. At first, we initialize all the global variables that are needed in the code.. Next, we initialize the display. In the loop function. At first we call the drawMenu function to draw the menu on the screen.. Then we read the value from the Rotary encoder and check if the button is pressed.. For example, if we are on the main UI screen and the first menu item is selected. If the value from the rotary encoder has increased the menuitem variable increases and in the next loop, the drawMenu function will draw the second menu item as selected.. If we now press the button of the rotary encoder, we navigate to the second page, where we set the value of the variable. Again using the rotary encoder, we can increase or decrease the value of the variable.

. If we press the button, we navigate back to the main menu page and page variable, decreases. Thats, the basic idea behind this menu.. We follow the same procedure for all the menu items and pages. The code is complex. It is over 400 lines, long., It seems complicated, but if you try it yourself, you are going to understand it more easily and you will be able to change it, expand it and use it in your own projects.. As always, you can find the code of the project in a link in the description, below. Thats it now. We know how to build complex menus either with or rotary encoder or with buttons.. I personally prefer buttons for my menus, but in some cases a rotary encoder is easier to use.. I would like to hear your opinion about this.. Do you prefer buttons or a rotary encoder to navigate through your menus? Please post your comments in the comments section, below. and dont forget to like the video and share it with your friends. If you find it interesting, Also consider subscribing to the channel and do click that bell or YouTube might not show you updates. As new videos come out., If you are going to be shopping for parts check out the affiliate links from the video description. Thats it for today guys thanks you very much watching.

 
 

arduino encoder library Video

 

 

 

 

 

 

arduino encoder library news

 

 

 

 

 

 

 

arduino encoder library Social

 

 

 

 

official.arduino
2019-10-02T19:32:52+0000

👋 Want to bring Tony Stark-like gesture control to your projects? Learn how with the BLE-enabled MKR WiFi 1010 and Nano 33 BLE Sense boards using the ArduinoBLE library.
safe image.php?d=AQDyi1ELcW4VGzhx&w=720&h=720&url=https%3A%2F%2Fhackster.imgix.net%2Fuploads%2Fattachments%2F997327%2Fblob dChOhNMmeF - arduino encoder library
official.arduino
2019-10-02T19:08:01+0000

Arduin-yo ho ho! A fairground favorite, the pirate ship is a fun way to explore the oscillation of a pendulum. How much fun, you ask? Access our Science Kit Physics Lab preview and see for yourself: http://bit.ly/2oC6L0Q

🔬 Now that you’ve gotten your feet wet, dive into the kit and enjoy all nine experiments. Order yours today: http://bit.ly/2MnQ7fr

70537898 550174072395145 8798850142103928832 n.jpg? nc cat=102& nc oc=AQmCfMPwMf1oPpYqFhzbxfnGdbrmsjZXrEEBy1ox5Z8EJtiYMADoFNZ5mnSNRgCCY74& nc ht=scontent - arduino encoder library

Most Parts- GPS Clock

COMedia C328-7640 Serial Camera First Image

 

 

Originally posted 2016-01-09 14:19:39.

(Visited 66 times, 1 visits today)

About The Author

You might be interested in

Comment (21)

  1. Would you show an example where you can read the temperature by selecting the menu with the menu? Can you help me to run different code from selected menus?

  2. I just looked at your code, can’t believe you don’t stick to such common sense practice such as defining the pins with names at the beginning, to make it more readable and easier to modify for other Arduinos, or slight variations in the connection scheme… Would you mind creating this update? Or since I am working on it would you like me to send you my version? Like this:
    #define BacklightPin 7 // pin controlling the backlight LED
    Then use BacklightPin wherever in your code you use 7 to indicate that pin – this is just general good practice, you should always do it like that!
    By the way would it be reasonable to use PWM to control the brightness of the backlight LED?

  3. I’m doing a thermastat. My control will be a 5-way switch, more akin to buttons I suppose. My wife has MS and the rotation of a knob requires complex wrist movements therefore I went with the 5-way.

  4. Most difficult solution seen, and it works, congrats, this code can at least be halved and still works My professor at varsity always said if you want a difficult answer ask a student. I first tried to understand the flow before changing it, and it was really difficult. A few switch statements and whala .. if then elseif have priority and is extremely difficult to read, but switch statements can easily be read if used in a state machine, even more if enums is used instead for constants (0,1,2,.. 6).

  5. Hi! I found your tutorial very interesting, let me ask more, if I want to click one to enter the submenu, duble click to exit then what function do I have to use, thank you

  6. nice job , well done, i have one question, whatever the values i am entering, it should save so next time if i switch on the arduino, i should get the saved setting not the default one, thanks

  7. the rotary encoder is always a cool one. but combine rotary encoder with switches, creates damm good interfacing panel. my personal favourite is SMD joysticks. thank you very much for this tutorial.

  8. Hi Nick! I want to add a “home screen” in the menu, but apparently there are only two pages to work with. How can i add more pages?

  9. the contrast should be set to values between 52 and 67 (varies from display to display) during setup, otherwise nothing is visible from the menu.

  10. Как сделать такое же перелистывание по нажатию на кнопки?

  11. My menu works but I can’t get sensor readings into it, my values are not updating at all.

    I have heard of state machine and the use of interrupts but I don’t see how to implement it with this code.

LEAVE YOUR COMMENT

Your email address will not be published. Required fields are marked *