Introduction: Arduino I2C LCD Driver Library and PackMan
This project is a comprehensive Arduino port of an earlier Instructable which can be found here;
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;
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.