Using LCD Displays ...
 
Notifications
Clear all

Using LCD Displays with Arduino

37 Posts
16 Users
3 Likes
6,396 Views
(@dronebot-workshop)
Workshop Guru Admin
Joined: 5 years ago
Posts: 1086
Topic starter  

Learn to use LCD displays with an Arduino. All types of LCDs, including I2C and display shields are covered here.

Article with code at https://dbot.ws/lcdarduino

Today in the workshop we will look at Liquid Crystal Displays or LCDs.

We will examine the use of two types of LCD displays - the common LCD1602 display module and a popular LCD Keypad Shield for the Arduino. We’ll also see how to use the I2C adapter for the LCD1602 display module.

LCDs are a very simple way to add display capabilities to your Arduino project. They are inexpensive, easy to use, and very versatile. They also don’t consume a lot of current so they are ideal for battery-powered projects.

I'll show you a couple of ways to interface an LCD with an Arduino, including the use of an I2C adapter. If you’re not familiar with the I2C (Inter-Integrated Circuit) bus it’s a very versatile method of adding sensors and peripherals to your Arduino using only a few wires. I’ll give a brief explanation about the operation of the IC2 bus in the video.

To use the I2C adapter we'll make use of a library called NewLiquidCrystal. I'll show you how to install it, you'll find the link to this library in the article at https://github.com/fmalpartida/New-LiquidCrystal. The library is actually a replacement for the Arduino LiquidCrystal library so you can use it for all your LCD sketches, not just the I2C ones.

We will also build something practical while we are at it - a digital temperature and humidity gauge. This will make use of the I2C adapter and the DHT22 Temperature and Humidity sensor.

The video, and the accompanying article, will also show you how to use a very common LCD Keypad Shield for the Arduino Uno. The neat thing about this device is how the pushbuttons are wired. I’ll explain that and show you a demonstration sketch that you can build upon for your own projects.

Here is the Table of Contents for this video:

00:00 - Introduction
04:27 - The LCD1602 Display Module
07:04 - Hooking up the LCD and Arduino
09:49 - Demo Sketch 1 - Hello World
12:59 - Demo Sketch 2 - Scroll
15:39 - Demo Sketch 3 - Custom Characters
20:00 - Introducing I2C
23:44 - Hooking up the I2C Adapter
26:15 - I2C Address Test
27:08- I2C Display Test
32:48 - Building the Temperature & Humidity Gauge
37:39 - LCD Keypad Shield
41:00 - LCD Keypad Shield Demo Sketch

By the way, I should mention I had a “slip of the tongue” while narrating this video. During the “Custom Character” demo I described the LCD as having a 5 x 7 matrix, it’s actually 5 x 8. Sorry about that! One extra row for you to define your custom characters.

The article accompanying this video at https://dbot.ws/lcdarduino

As usual, the article has links to more resources and to a ZIP file with all of the code you see displayed here.

Hope you enjoy this video and that you use it to display something wonderful in your next Arduino project!

"Never trust a computer you can’t throw out a window." — Steve Wozniak


   
VVV reacted
Quote
(@boggiano)
Member
Joined: 4 years ago
Posts: 17
 

The library https://github.com/fmalpartida/New-LiquidCrystal
is gone (404 error).
Is there a new repository or any other replacement in order to follow the video ?

Thanks

 


   
ReplyQuote
(@dronebot-workshop)
Workshop Guru Admin
Joined: 5 years ago
Posts: 1086
Topic starter  

@boggiano

Yes, unfortunately, that happens. 

If you are using the I2C backpack with your display you might want to check out the LiquidCrystal_PCF8574 Library.  For an example of using it see the video and article I released yesterday on PlatformIO, as I use it there.

Otherwise, there are several libraries for LCD displays that you can access in the Library Manager.

😎

Bill

"Never trust a computer you can’t throw out a window." — Steve Wozniak


   
ReplyQuote
(@boggiano)
Member
Joined: 4 years ago
Posts: 17
 

Thank you very much @Bill,
I was able to use this LiquidCristal_I2C library, in the meantime:

#include <LiquidCrystal_I2C.h>
// https://github.com/johnrickman/LiquidCrystal_I2C

just with some few little modifications.
Anyway, I am going to try that one as well!

Can I suggest to add this tips in the description of the old video?
Making it works, could a challange for someone or a reason of gave it up for others ! 😀

Thanks a lot, Bill, for your sharing!

 


   
ReplyQuote
Centari
(@centari)
Member
Joined: 4 years ago
Posts: 44
 

I'm still learning my way around here, and this seems to be the most recent maintenance thread.  I just wanted to point out that in "Using LCD Displays with Arduino" the links for the 'NewLiquidCrystal' header file are no longer valid.  Returns 404 error from bitbucket.


   
ReplyQuote
(@dronebot-workshop)
Workshop Guru Admin
Joined: 5 years ago
Posts: 1086
Topic starter  

@centari

Moved to the correct Topic, where this question has already been addressed.

"Never trust a computer you can’t throw out a window." — Steve Wozniak


   
Centari reacted
ReplyQuote
Centari
(@centari)
Member
Joined: 4 years ago
Posts: 44
 

@dronebot-workshop  Thank you


   
ReplyQuote
Sumanta
(@sumanta)
Member
Joined: 3 years ago
Posts: 197
 

This video is that very video, which introduced me to this channel. How lucky you were to upload this video!

You had earned a subscriber that day. 😉 


   
ReplyQuote
(@martin-richard)
Member
Joined: 3 years ago
Posts: 9
 

Does anyone know why i get an error message when uploading the first I2C program to arduino the error message is "POSITIVE"is not defined

Regards

 

Martin


   
ReplyQuote
(@ade_o)
Member
Joined: 4 years ago
Posts: 1
 

hi martin did you ever figure this out i have the same issue


   
ReplyQuote
(@yurkshirelad)
Member
Joined: 3 years ago
Posts: 493
 

A code fragment for us to look at might help. Or try to create the most basic application code that reproduces the problem.


   
ReplyQuote
(@richardbr)
Member
Joined: 3 years ago
Posts: 7
 

I have had the same problem.  The link in the article to the LiquidCrystal-i2c library doesn't work.  This video was made 3 years ago so things change.  I tried other LiquidCrystal-i2c  libraries to no avail.  I like the Dronebotworkshop because things work.  But maybe not after 3 years.  


   
ReplyQuote
MadMisha
(@madmisha)
Member
Joined: 4 years ago
Posts: 340
 

I am copying my answer from another post about this since I've seen the problem here too.

Unfortunately, I do not have that library so I cannot test it out. I also don't know what POSITIVE is. As far as I know, that is not a C/C++ command. Try just deleting that and the comma before it and see if it compiles. The library manager should have one from Adafruit available if you search LCD and it should work exactly the same but without that POSITIVE there.

Edit: Actually, I realized it was the backlight and that library does not support that. And I believe the POSITIVE is the backlight polarity, maybe... 

 

Here is one that I think will work but things are passed in a different order enjoyneering LiquidCrystal_I2C

It was the closest I could fine. Let me know if that works.

 

LiquidCrystal_I2C lcd(i2c_addr, rs, rw, en, bl, d4, d5, d6, d7, POSITIVE);

   
ReplyQuote
(@yurkshirelad)
Member
Joined: 3 years ago
Posts: 493
 

POSITIVE is defined in the LiquidCrystal library:

https://github.com/enjoyneering/LiquidCrystal_I2C/blob/a5e94e9ff075cffa510b5474e6e68a221fa2d51f/src/LiquidCrystal_I2C.h#L165

Are you including the header file correctly? If you are, then I wonder if the order of includes makes a difference: put the LiquidCrystal include last.

I'd post a code example, but I always have problems posting code on these forums.


   
ReplyQuote
MadMisha
(@madmisha)
Member
Joined: 4 years ago
Posts: 340
 

@yurkshirelad

The problem they are having is that the original library is no longer available(so I couldn't see the reference in the library since I do not have it, that's why I included it in the edit after I found one similar) and that the fact that it is named the same as a popular library. But please let me know if Bills code works with the alternate library and the change in code I posted. It will take me some time to dig out my LCD display to test. But I went through the library and everything looks like it is called the same.


   
ReplyQuote
Page 1 / 3