Error with I2C LCD

Hey all, I am using the code exactly as shown here but I am getting the following error when trying to verify
http://arduino.cc/playground/Code/I2CPortExpanderAndLCDs

lcd_i2c.cpp: In function 'void setup()':
lcd_i2c:30: error: 'WriteLCD' was not declared in this scope

any ideas here?

The WriteLCD function isn't implemented. That's not your fault.

cool, any ideas how to fix it?

My guess would be to replace calls to WriteLCD with WriteLCDByte or with SendToLCD but it's just a guess. I didn't write the code.

that is far beyond my comprehension. How did unusable code end up on the Arduino website?

WindowMaker:
that is far beyond my comprehension.

Add the word "Byte" where you see the word "WriteLCD".

So WriteLCD(ADDR,'a'); would become WriteLCDByte(ADDR,'a');

WindowMaker:
How did unusable code end up on the Arduino website?

Anyone can add pages to the Playground. Maybe whoever posted that page didn't proofread their own code.

I guess a question for you is, what module are you using? Are you sure that code will work with whatever you are using?

thanks for the explanation. when I add Byte, it goes to this error

lcd_i2c:32: error: 'class LCDI2C4Bit' has no member named 'WriteLCDByte'

Change setup in the example code to read:

void setup()
{
  Serial.begin(9600);
  Wire.begin(); // join i2c bus (address optional for master)
  lcd.init();
  lcd.printIn("test");
  lcd.print('a');
  lcd.clear();
  lcd.print('c');
  lcd.cursorTo(0,0);
  lcd.printIn("0");
  lcd.cursorTo(1,0);
  lcd.printIn("1");
  lcd.cursorTo(2,0);
  lcd.printIn("2");
  lcd.cursorTo(3,0);
  lcd.printIn("3");
}

Then it compiles.

Yes it does! Awesome!

One final question :smiley:

How do I find the device address? I am using the MCP23008 (i have more than one running), I have A0, A1, and A2 wired to 5v so my understanding would be that the address is 0100111. Do I just put that int he brackets at Wire.begin?

here is the datasheet

There is a I2C scanner here:

If you have more than one MCP23008 set the A0, A1, A2 to different combinations (eg. Gnd/5V/Gnd and so on).

This is the line you change:

int ADDR = 0xA7;

Since you want (say) 3 devices you could have:

LCDI2C4Bit lcd1 = LCDI2C4Bit(0b0100000,4,20);
LCDI2C4Bit lcd2 = LCDI2C4Bit(0b0100001,4,20);
LCDI2C4Bit lcd3 = LCDI2C4Bit(0b0100010,4,20);

That way you have three instances of the class with different addresses for each one. Although I think that does an unnecessary copy operation. How about:

LCDI2C4Bit lcd1 (0b0100000, 4, 20);
LCDI2C4Bit lcd2 (0b0100001, 4, 20);
LCDI2C4Bit lcd3 (0b0100010, 4, 20);