Hello, I just spent a good couple of hours getting my Bela to talk to a small 16x2 LCD panel so I thought I'd share my experience and code in case someone else wants to do it. This is C++ by the way, there was another thread about doing it over Pd.
I ordered my panel on eBay, similar to this one:
http://www.ebay.com/itm/Yellow-Display-IIC-I2C-TWI-SP-I-Serial-Interface-1602-16X2-LCD-Module-TOP-/321558565771?hash=item4ade62538b:g:R4gAAOSwZVlXmX5q
Note that it's not just the bare LCD panel, it has a small serial interface board. (otherwise you'd need lots of I/O pins, which I need for other things)
The panel talks at 5V levels so connecting it straight to the 3.3V I2C bus connector on the Bela (probably) won't work. To get around this, I got a small logic level converter board. Mine is a 4-channel, but only two are needed (for SCL and SDA). This is an example of a 2-ch, usually a few dollars, shipped.
For prototyping I ran my 5V from the analog out 5V but I'll change that to a stronger supply as the display is a bit faded in this one.
Hardware:
- Connect the 5V supply to the Display's I2C VCC and to the converter board's "high-voltage" pin.
- Run the 3.3V from the Bela's I2C to the converter's "low-voltage".
- Run a GND from one of Bela's GND pins to the converter board and display's GND.
- Then run the Bela's I2C SDA and SCL signals each to a LV input of the converter board.
- Run the HV output for each of those two signals to the display's corresponding pins on I2C.
This sounds more complicated than it is. You're just powering the converter board and putting it between the two serial wires to convert levels.
Another option I read in the Pd thread is to use the analog audio outputs as 5V signals but then you'd have to deal with bit conversion and mostly render-loop sync for sending out your serial data. Seems the tiny converter board option is easier...
Software:
The library that ships with these things is meant for Arduino so a few things are missing and don't compile. I've modified the library source using the "capacitive-touch" example to compile and work with Bela's I2C library. From what I can tell this is the same "LiquidCrystal_I2C" V1 that's all over the net, but credit to the original author has been removed :-(
It's just two files so should be easy to drop in. Here they are. Sorry if it looks a mess, it wasn't that pretty to begin with and I've just hacked it to a functional level for Bela.
https://gist.github.com/anonymous/158f5e9fcf74f49fda89be9045948bbc
Check out the header for the API. I haven't tested all of it, but what I did worked fine. Example code in my render.cpp's setup()
LiquidCrystal_I2C lcd(0x3F, 16, 2); // My 16 x 2 panel sits at I2C address 0x3F, some are at 0x20 or 0x27, check when you buy
lcd.init();
lcd.noCursor();
lcd.print("Hello Bela!");
lcd.backlight();
lcd.setCursor(0, 1);
lcd.print("It works, yippee!");
And here's the result of that running on my pieced together prototype:
Hope this helps someone.