With this MicroLib your Arduino board will be able to control a standard LCD-display, based on the Hitachi HD44780 display-controller and connected through a PCF8574 based I2C-adapter. It consist of the single header file MicroLib_LCD_I2C_PCF8574.h which must be included after including the Wire-library or the Software I2C-library - yes, this library works fine with the Software I2C library, see the included HelloWorld example programs.
The standard LiquidCrystal library does only support LCD-displays, connected directly to the Arduino I/O pins, no I2C. If you want to use an I2C-adapter only the New-LiquidCrystal-library from Fernando Malpartida is available which can replace the original LiquidCrystal-lib entirely.
Compared to those libraries, the MicroLib greatly reduces the size of the compiled code and the depth of the call-stack, by simply replacing sub-routines that would just call another subroutine to send a command to the display with C pre-processor macros and omitting all checks; You must know what you are doing: If you want to write a text into row 3 of a 16x2 display the MicroLib will happily store your data into the LCD-display controllers memory - don't be surprised if you don't see it!
The MicroLibrary is not compatible to any of the standard LiquidCrystal libraries at all, but here is the advantage in numbers:
If you compile the included HelloWorld example program with Fernandos NewLiquidCrystal-library the resulting code occupies 3,732 bytes of program memory, if you compile it with the MicroLib this amount goes down to 2,778 bytes. Of course, this is an extreme example, in larger programs the gain is not so exorbitant, but if you just have 30,720 bytes of program memory in your Arduino Nano every byte counts...
Almost all I2C-adapters that are being sold in the internet are following the schema below to connect to the LCD-display:
|PCF8574 PortBit||LCD-display pin||Pin Name||Function|
|1||5||RW||Read not Write|
|3||11||A||Backlight Anode (through inverting transistor)|
Display = LCD_Init(LCD_I2C_ADDR,20,4); // 20x4 display
LCD_DefineChar(&Display,1,8,v_CharBuffer); // define character 1
LCD_At(Display,0,1); // position cursor to the left of the second row
THE standard example: Print the text "Hello World!" to the connected LCD display. Connect your LCD-Display to the pins A5 (SCL, yellow wire) and A4 (SDA, green wire) and run this program to see "Hello World" on your display.
By changing line 17 of the program from
switching between the new LiquidCrystal library and the MicroLib you can compare the difference in code-size.Back to the top of the document.
Another simple example program which demonstrates how to define all eight custom characters and cyclically displays the whole character-set in chunks of 16 characters. This program can be used with the standard Wire or the Software I2C library, see line 14 in the source-code.Back to the top of the document.