Pages

Monday, 17 May 2010

I2C LCD board

In the previous post I mentioned that most of the boards I'm working on use I2C™ port expanders. The latest is an LCD driver which uses a Phillips PCF8574 I2C 8-bit expander to drive a 2x16 character LCD. The only Arduino pins used by the display are pins 27/28; they can be used to drive other I2C boards as well.

The Arduino software to drive the LCD is very simple. Here's the code used for the picture above:


#include <:lcdi2c.h>
#include <wire.h>

int ADDR = 0x21;
LCDI2C lcd = LCDI2C(ADDR);

void setup()
{
  Wire.begin();
  lcd.init();
  lcd.print("test"); 
}

void loop()
{
 lcd.cursorTo(2,0);
 lcd.print("time:");
 lcd.cursorTo(2,6);
  // print the number of seconds since reset:
  lcd.print(millis()/1000);
}