Arduino with I2C LCD and Rotary Encoder

preview_player
Показать описание
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:

For a written version of these instructions, refer to:

The Arduino sketch uses the following external libraries:

The sketch also utilizes code from Simon Merrett’s instructable “Improved Arduino Rotary Encoder Reading”

Check out my other Arduino projects that use the I2C LCD and Rotary Encoder as described in this video:
Рекомендации по теме
Комментарии
Автор

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 !

Wrighmachining
Автор

Love it John. Nice mix of humor along with very thorough and easy to follow instruction.

joshgapp
Автор

Thanks for your time giving us a good tip.

realcomsolucoes
Автор

Thanks for the video. Being a beginner at this your video really helps me better understand the sketch terms and building.

eddiejones
Автор

Thank you John, your video was very helpful

christosstylianou
Автор

Crystal clear tutorial
Your explanations are SO clear and usefull.
Thanks👌

robdavidowitz
Автор

It was very helpful. clear explenation. Thanks a lot.

umitozdemir
Автор

Very good, clear, and sensible explanation. Well done and thank you. This is learning at its best.

chbonnici
Автор

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.

garysplace
Автор

Has anyone attempted with an Arduino mega, even adapting the code doesn't seem to work

Minizom
Автор

Excellent explanation thanks I want make LCD menu for operate stepper motor with given speed and steps. thanks for your help.

pradeeplaptop
Автор

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.

dilipsuthar
Автор

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?

alexptvz
Автор

Thank for your video, can Rotary Encoder be connect to M5stack core 2 or Mstick C

echosoundlight
Автор

Hi can you please explain how to modify this program for OLED display?

sumeshak
Автор

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:

In function 'void initializeLcd()':
error: no matching function for call to 'LiquidCrystal_I2C::begin()'
lcd.begin();
^
In file included from
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 );
^~~~~
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

robdavidowitz
Автор

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?

sarojpradhan
Автор

for me the lcd.begin(); does not work, but if i use lcd.init(); it does do you know why?
very nice video btw.

brraam
Автор

Music box was enough complicated as your examples.

LemonTreeNOTfree