Introduction: Arduino I2C LCD Driver Library and PackMan

This project is a comprehensive Arduino port of an earlier Instructable which can be found here;

https://www.instructables.com/id/Microchip-PIC-Library-to-Control-a-20-by-4-LCD-ove/

Which was snappily titled...

'Microchip PIC Library to Control a 20 by 4 LCD over I2C'

It's my first go at writing a C++ Arduino Library so apologies if it's not in 100% perfect Arduino 'speak'.

It's been fully tested without any issues up to a maximum of 4 LCDs of varying dimensions as in the attached picture above.

The serial I2C conversion to LCD parallel is achieved through the use of a conversion module purchased from Ebay as detailed in the aforementioned Instructable which is based around the PCF8574 IO Expander.

I reverse engineered the PCB and have provided a copy of the circuit above should you wish to make your own from scratch. Though given the crazy price of £1.79, I heartily recommend you buy one rather than expend the effort to munge one together.

A copy of the full zipped library is included below.

To 'install' it you should follow the Arduino library installation instructions for importing a .zip library given here;

https://www.arduino.cc/en/Guide/Libraries

The library gives access to all the HD44780 LCD functionality along with read access of the display to allow reading of DD and CG ram along with the busy flag if you need to poll the display for availability on slow operations. It achieves this by configuring the LCD into 4bit mode.

The zip file also contains a tool to help create your own custom characters.

Step 1: What's in the Box?

Once installed, along side the usual Arduino Library directories/files you will find a directory labelled 'info' into which I have bundled lots of useful details on I2C (the spec.), how to calculate Rp values, HD44780 LCD, PCF8574 etc.

I also included a PDF named 'I2C_LCD_With_Arduino' which has some useful information/tips when using I2C which I wrote to augment this Instructable and should be read in conjunction with it.

It comes with many examples on how to use the library.

The Fritzing circuit and YouTube video link above are one such example of an animation across two displays and how to connect it up.

If you purchase the parts pre-assembled all you will need is a soldering iron to connect the LCD and some rudimentary electronics knowledge and you're good to go!

Step 2: Animations

I also included a spread sheet that allows you to quickly create custom characters and auto generate the code. I used it to create the PackMan and Clyde animations given in Step 1.

The YouTube video link above details how to use the auto code generation tool which is a modified version of the one I used for my Evil Eyes Instructable. Only this time I made a better job of the video. :-)

I also included many example animations in the spread sheet you can use 'out of the box'.

Once you generate the code you can drop it straight into the sketch named 'LCD_I2C_PCF8574_CharGenTest.ino' to see it run.

Note : For the auto code generation to work, the spread sheet will need macros turned on. If this worries you. Keep macros off, open the spread sheet press Alt-F11. The VBA editor will open and you can review the code to ensure there is nothing untoward in it.

The library and all the examples are provided free to use in whatever way you see fit (just make a mention of me), though it comes unsupported.

Happy inventing.

Comments

author
AlanGP made it!(author)2017-02-01

Steve,

Many thanks for this - just what I needed.

Alan

author
SteveQuinn made it!(author)2017-02-01

Hi Alan,

You're welcome.

Regards

SteveQ

author
ArcAiN6 made it!(author)2016-06-22

just out of curiosity, where did you find the 20x4 LCD and I2C backpack fritzing part files? I've been searching all day, and i can't find them anywhere!

author
SteveQuinn made it!(author)2016-06-22

Hi ArcAiN6,

I made my own, hence the general Fritzing rant. Step 2 Note 2. https://www.instructables.com/id/Animated-Halloween-Evil-Eyes/

BR

SteveQ

author
Thijxx made it!(author)2015-11-21

How do I change the pins? I use a Mini and it has no A4 and A5. There are no pins in the example code so I wonder where I should change it.

author
Thijxx made it!(author)2015-11-21

found it :) those pins are hidden next to the reset switch

author
SteveQuinn made it!(author)2015-11-22

Hi Thijxx,

Glad to have been of no help to you. Please let me know if I can't help you in future.

:-)

author
momoluv made it!(author)2015-10-14

I don't know much about technology, but I know that this is a great instructable

author
SteveQuinn made it!(author)2015-10-15

Fine praise indeed, coming from such a prolific Instructable(er) as yourself with 124 Instructables under your belt.

I'll take that as a great compliment. :-)

Fantastic YouTube Channel BTW.

author
momoluv made it!(author)2015-10-16

Thanks so much for checking it out! May you have a long and profitable instructabkes journey :)

author
dmwatkins made it!(author)2015-10-14

I thought I was the only one with those 40x2 displays lol. I got a bunch from an old tube delivery system.

author
SteveQuinn made it!(author)2015-10-15

I actually purchased this back in the 90s! It's an original Hitachi. Now I've done the Instructable I guess it'll go back into storage for another 20 years. :-)

author
dmwatkins made it!(author)2015-10-15

No! Use it with pride! It's unique!

Great Instructable, by the way!