A little bit of everything

LCD i2c Libraries for Arduino


Currently they support the 2 line and 4 line displays from web4robots.com




This is a library I put together to use intelligent i2c LCD displays.

For the latest news and developments, please see the Wiki in the Arduino playground.

I am not active with the Arduino but have updated this page to make the libraries available on my web server as Apple has closed down mobile me.



Ken Terrel updated the LCDi2cW library to work with the Arduino 1.0.2 IDE He sent me the updated files to share with everyone. They are in my public Folders with a filename of LCDi2cW-1_0_2.zip Thanks Ken!



Download from My Public Folders

My LCDi2c library in the Arduino playground, and the discussion in the forums.

My LCD API Documentation in the Arduino playground, and the discussion in the forums.



My goal is to have a set of libraries that can be made universal and work with multiple manufactures i2c LCD displays.
I want it to be as simple to use as serial.print, and allow for advanced features if a display has them available.
I am trying to keep it compatible with the original LCD libraries for 4 and 8 bit displays.

The advantage of using an i2c LCD on the Arduino is that it only takes 2 wires plus power to support the display.

i2c or two wire uses the following pins on the Arduino (Note that the Mega uses different pins)

Uses Analog pin 4 - SDA
Uses Analog pin 5 - SCL



I am also encouraging shield developers that do not have LCD support on their shields to adopt a standard header configuration for i2c expansion.

That standard is:

Header Pin Arduino Pin

1 +5 Volts
2 Ground
3 Pin 4(SDA)
4 Pin 5(SDA)

Optional Pins 5 and 6

5 Reserved 1
6 Reserved 2

The reserved pins are for things like interrupts that some of the i2c devices might need. They are not connected but could be wired to a particular pin for each device.
The advantages of this idea is that for simple i2c bus devices only 4 pins are needed, and they could be plugged into the shield directly.
If we adapt this standard, companies making breakout boards, could make the boards pin compatible with this standard, and they would plug directly into the shields.

For simple things only the first 4 pins are needed.

News:

Ran Talbott is helping to develop and maintain the library. The latest release has his contributed code.

Version 0.4 released 2/27/2009

Added Ran Talbott’s code for custom characters and graphics.




History:

I purchased a display on ebay that was sold by web4robots.com, it is a 2x16 character LCD. I wrote the inital library for my self, and posted about it on the Arduino forum

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1236204212



The following displays are supported

web4robots.com 2x16 line display Supports both the LCD and the Keypad interface, keyboard interrupt is not supported.
Currently there is no support for the graphing functions
4x20 line display Display is on hand, and I will be testing it.


Tony at web4robots.com was kind enough to send me a 4x20 line display for testing. I will be adding support for some new features of this display in the near future.

If you are a manufacture and would like your display supported please contact me.
My email address is dale at wentztech.com



Here is a simple classic “Hello World” Sketch using my i2c LCD library.

Sample Hello World Script
-------
// example use of LCDI2C library with the web4robot.com i2C 2x16 lcd display

#include
#include

LCDI2C lcd = LCDI2C(2,16,0x4C,0); // Number of lines and i2c address of the display

void setup() {

lcd.init(); // Init the display, clears the display

lcd.print("Hello World!"); // Classic Hello World!

}

void loop()
{

}

--------------

Command Summary:


Init with

LCDI2C lcd = LCDI2C(2,16,0x4C,0); // Where number of lines = 2, Columns = 16 and 0x4C is the i2c address of the display, type of display(Future Use)


The following commands are available for within the library.


init() Init the LCD and library functions, Clears the display, turns off the cursors

command(command) Write a command not supported yet in the library to the display

position(Row, Column) Move the cursor to position valid range is Row[0-3], Column[0,19]

setCursor(Row,Column) Same as position

print(val) Uses the inherited print command so you can do things like lcd.print(int,DEC);

println(val) Uses the inherited print command so you can do things like lcd.print(int,DEC);

printstr(string) Print a string to the display

write(byte) Raw write a single byte to the display

clear() Clear the display and place the cursor at 0,0

home() Home the cursor to 0,0 but do not clear the display

on() Turn the LCD display on

off() Turn the LCD display off (not backlight does not go off)

cursor_on() Turn the blinking line cursor on

cursor_off() Turn the blinking line cursor off

blink_on() Turn the blinking block cursor on

blink_off() Turn the blinking block cursor on

left() Move the cursor to the left

right() Move the cursor to the right

keypad() read a value from the keypad. Returns 0 if no key press is in the buffer

init_bargraph(mode) Init graphics functions where mode can be
LCDI2C_VERTICAL_BAR_GRAPH
LCDI2C_HORIZONTAL_BAR_GRAPH
LCDI2C_HORIZONTAL_LINE_GRAPH

draw_horizontal_graph(row,col,len,end)

draw_vertical_graph(row,col,len,end)

load_custom_character(char_num,*char)

set_backlight_brightness(val)

set_contrast(val)

-------------------------------------------------------------------


Version 0.1 3/4/2009 Initial Release

Version 0.2 3/12/2009

Change the print and println so they use the inherited print library.
This allows us to do things like lcd.print(int,DEC);

Changed the commandWrite(command) to command(command) to bring it more in line with the crystaldisplay library

Changed the position command to setCursor to bring it more in line with the crystaldisplay library

Cleaned up the code a bit

Version 0.3 3/16/2009

Optimized code

Created new Samples

Version 0.4 3/27/09

Added strprint, custom characters, graphing functions, brightness and contrast classes contributed by Ran Talbott
Also added some sample sketchs to show off the functions.
Fixed name so samples load up correctly

Things to do:

Add support to new features being added to the web4robot display.

Add support for the following displays
http://www.robot-electronics.co.uk/htm/Lcd03tech.htm
www.newhavendisplay.com

Future

Possibly Add support for the i2c displays from
www.spikenzielabs.com
www.hvwtech.com
www.robotshop.com
www.channaa.com

(If you are the manufacture of an i2c based LCD character display and would like you display included in the library
Please contact me. I will require a sample display and or driver board to keep on hand for testingfrom you.)



For the most up-to-date information on this library please goto http://www.wentztech.com/radio


blog comments powered by Disqus