Arduino with I2C LCD and Rotary Encoder
Vložit
- čas přidán 8. 07. 2024
- This tutorial shows how to use an I2C 16x2 Character LCD and a KY-040 Rotary Encoder for local control and readout with an Arduino Uno. The parts cost less than $10 and can be assembled with no soldering. I believe that this makes it the simplest, cheapest, and easiest way to create a local user interface for an Arduino project.
Feel free to skip ahead to the section that is of most interest to you.
1:04 - Purchasing the Parts
4:12 - Assembly of the Hardware
7:38 - Walkthrough of the Arduino Sketch
11:44 - Demonstration
The Arduino sketch shown in this video can be found at:
github.com/jpsrmiller/rotary-...
For a written version of these instructions, refer to:
buildmusic.net/tutorials/user...
The Arduino sketch uses the following external libraries:
OneButton: github.com/mathertel/OneButton
Liquid Crystal I2C: github.com/fdebrabander/Ardui...
The sketch also utilizes code from Simon Merrett’s instructable “Improved Arduino Rotary Encoder Reading”
www.instructables.com/id/Impr...
Parts for this project were purchased from Ali Express (www.aliexpress.com/) and Adafruit (www.adafruit.com/).
Check out my other Arduino projects that use the I2C LCD and Rotary Encoder as described in this video:
Toastmasters Automatic Timing Light - autotiminglight.com/
Build Your Music - Robotic Xylophone - buildmusic.net/
Thanks for the video. Being a beginner at this your video really helps me better understand the sketch terms and building.
Very good ,clear, and sensible explanation. Well done and thank you. This is learning at its best.
Love it John. Nice mix of humor along with very thorough and easy to follow instruction.
Thanks for your time giving us a good tip.
Nice demo John glad you helped me out
Crystal clear tutorial
Your explanations are SO clear and usefull.
Thanks👌
Excellent teaching method. Thanks.
Hey John pretty well laid out thank you. The code was pretty comprehensive as well for myself trying to learn and modify code to fit what I need.
Keep up the good work !
Thank you John, your video was very helpful
Mil gracias. Un abrazo desde Colombia
It was very helpful. clear explenation. Thanks a lot.
Thanks for the video, very useful!
Great Job. Thank you.
Saludos desde Ecuador 🇪🇨, éxito
hanks lot Sir.. You helping us..
YOU DESERVE MILLIONS OF SUBSRICBERS
спасибо. доступно, позновательно
good tutorial!
Thanks a lot
Hi, I had an issue with the encoder not incrementing and was wondering if you had any ideas for me on that issue. The push button works fine but when I turn the knob nothing happens.
Excellent explanation thanks I want make LCD menu for operate stepper motor with given speed and steps. thanks for your help.
Thank for your video, can Rotary Encoder be connect to M5stack core 2 or Mstick C
Hi can you please explain how to modify this program for OLED display?
Hi John
I m new to Aurdino, saw ur vdo its very informative. want to have some more information on ur above vdo. Can we do preset counter using the above material. That is we set some count on LCD and when we rotate the encoder in reverse direction and as soon the counts reaches to "0" (zero) we can generate a flag which will operate a relay.
Can u help me in this above project with its sketch and bill of material.
Has anyone attempted with an Arduino mega, even adapting the code doesn't seem to work
man its very clean code and and very structured video. I repeat the same steps, but sometimes when I turn encoder value on LCD not been changed, it's like freezing for little time or some like this. Maybe you have an idea why it happens?
for me the lcd.begin(); does not work, but if i use lcd.init(); it does do you know why?
very nice video btw.
HI John
I built this project and worked fine.
Now i want to realise menu system with the help from your code,
where rotaryleft and rotaryright function will navigate up and down through menu items and encoder click event will select the menuitem.
i tried one menu system using simple menu library.my problem is every function called in rotaryclick subroutine works perfectly but if i call same functions in rotaryleft and rotaryright subroutine it doesnot work. any idea?
Have you solved this?
Music box was enough complicated as your examples.
John,
I have copied and pasted this sketch
Changed I2C adress to 0*27 and set the display 2 2*16
On compiling, I get the following error:
C:\Users\ABCD\AppData\Local\Temp\.arduinoIDE-unsaved2023030-18628-fhzkzm.s5a15\sketch_jan30d\sketch_jan30d.ino: In function 'void initializeLcd()':
C:\Users\ABCD\AppData\Local\Temp\.arduinoIDE-unsaved2023030-18628-fhzkzm.s5a15\sketch_jan30d\sketch_jan30d.ino:197:12: error: no matching function for call to 'LiquidCrystal_I2C::begin()'
lcd.begin();
^
In file included from C:\Users\ABCD\AppData\Local\Temp\.arduinoIDE-unsaved2023030-18628-fhzkzm.s5a15\sketch_jan30d\sketch_jan30d.ino:42:0:
c:\Data\Dropbox\Arduino\Projects\Sous_Vide_001\libraries\LiquidCrystal_I2C/LiquidCrystal_I2C.h:58:8: note: candidate: void LiquidCrystal_I2C::begin(uint8_t, uint8_t, uint8_t)
void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS );
^~~~~
c:\Data\Dropbox\Arduino\Projects\Sous_Vide_001\libraries\LiquidCrystal_I2C/LiquidCrystal_I2C.h:58:8: note: candidate expects 3 arguments, 0 provided
exit status 1
Compilation error: no matching function for call to 'LiquidCrystal_I2C::begin()'
The compile stops at the lcd.begin() below
void initializeLcd()
{
lcd.begin();
lcd.backlight();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(F("Test LCD & Rotry"));
}
Can you please assist.
Rob
Any chance your available for help?
aliexpress is banned in India.