I had to piece this together from several other web resources, but I hope this will get some people headed in the right direction.
I just recently received an Arduino and wanted to get it to talk to a Matrix Orbital display I had, model LCD-2041, revision 1.50, which has a serial port and I2C.
This is how I got it to work over I2C.
First, the LCD itself has some jumpers that needed to be adjusted, making it talk I2C instead of RS232. These are clearly labeled on the board.
The two wires for I2C were attached to Analog pins 4 and 5, according to Keith's blog reference above. +5V and GND were also attached to the appropriate areas on the Arduino.
Now came the software. Here's the resulting sketch:
#include <Wire.h>
#include <stdlib.h>
int value = 0;
int volts = 0;
char valueStr[5];
void setup() {
Wire.begin();
Serial.begin(9600);
}
void loop() {
Wire.beginTransmission(0x2E);
// These next two bytes send the command to clear the display.
Wire.send(254);
Wire.send(88);
value = analogRead(1);
volts = ( ( 5 * value ) / 1024 );
Serial.println(volts);
itoa(volts, valueStr, 10);
Wire.send(valueStr);
volts = ( ( 5 * value ) / 1024.0 ) * 100;
itoa(volts, valueStr, 10);
Wire.send(valueStr);
Wire.send(" volts");
Wire.endTransmission();
delay(500);
}
This reads the voltage value of a potentiometer attached to Analog pin 1, and prints out the result to the LCD screen. The decimal point isn't there - the first digit is doubled-up. I'm working on that.
Anyway, the biggest stumbling block was getting the appropriate I2C address for the device. This was poorly documented due to a typo in the Matrix Orbital documentation, which mislabels the jumpers by starting at J0 in some places but J1 in others.
After a little troubleshooting it turns out that J0 is the correct starting point, and reading the documentation with that in mind leads you in the right direction. In any case, Matrix Orbital uses 8-bit LCD addresses whereas the Wire.h library expects 7-bit.
Looking in the documentation for this Matrix Orbital, with J1 and J2 closed, J0 and J3 open, you're given an address of 5C, which is in Hex. This converts to 01011100 in 8-bit binary. To convert this to 7-bit binary, shift by dropping the first bit, and writing it as 00101110, then convert back to Hex to get 2E.
That's what I placed in the code above, as the argument to Wire.BeginTransmission().
Also, the Wire.Send() doesn't actually write to the display until you call EndTransmission().