
Port of the Arduino library with the same library. Includes a instance of the Print library from arduino
Summary
A Conversion of the Arduino LiquidCrystal_I2C by Frank de Brabander to MBED
Version of original Library: 1.1.2
Information from the original library: The library allows to control I2C displays with functions extremely similar to LiquidCrystal library.
Original Github: https://github.com/johnrickman/LiquidCrystal_I2C
Code Example
This is a working example using the basic library features
example.cpp
#include "LiquidCrystal_I2C.h" LiquidCrystal_I2C lcd(0x27, 20, 4, I2C_SDA, I2C_SCL); void setup(); void loop(); //Arduino style setup function void setup() { lcd.init(); for (int i = 0; i < 3; i++) { lcd.backlight(); wait_ms(250); lcd.noBacklight(); wait_ms(250); } lcd.backlight(); lcd.setCursor(3, 0); // Start at character 4 on line 0 lcd.print("Hello, world!"); wait_ms(500); lcd.setCursor(2, 1); lcd.print("From YourDuino"); wait_ms(500); lcd.setCursor(0, 2); lcd.print("20 by 4 Line Display"); lcd.setCursor(1, 3); wait_ms(1000); lcd.print("DVSProductions.de"); wait_ms(8000); } //print some random characters void loop() { //lcd.setCursor(rand() % 20, rand() % 4); //lcd.print(rand() % 10); for (int x = 0; x != 20; x++) for (int y = 0; y != 20; y++) lcd.print(rand() % 10); } //Behave like an Arduino int main() { setup(); while (true)loop(); }
Misc
It is important to note that the library requires the init function to be called before sending any data. Instead of the arduino typical:
arduino.ino
LiquidCrystal_I2C lcd(0x27, 20, 4); void setup(){ lcd.begin(20, 4); }
We pass the pins and size to the constructor and then just call the init function:
mbed.cpp
LiquidCrystal_I2C lcd(0x27, 20, 4, I2C_SDA, I2C_SCL); void setup(){ lcd.init(); }
Also important is that the begin function still has value. It is now able to change the size of the LCD after the constructor. This might have few applications, but it is more powerful than the Arduino version, where the parameters had barely any use.