This guide will hopefully walks you through the assembly of the I2C LCD extra IO to connect it to an LCD and then to an Arduino.
If you are only interested in the IO expansion capability of the module, or you have it fully assembled with an LCD, skip to the Connection to Arduino Section.
Putting together the backpack onto an LCD is a quick process and should take only a few minutes with a soldering iron. You only need to solder a 16 pin header to the LCD and then to the backpack.
The I2C LCD extra IO comes with the control 5 pin 2.54mm (0.1") header already fitted (IF - BL, SCL SDA, GND, VDD).
- Solder a 16-pin 2.54mm (0.1") pin header to the LCD.
- Attach the backpack by aligning the LCD header connector with the I2C LCD extra IO and solder them together. If you would like to remove and replace the LCD at some point, you can use a 16-pin 2.54mm (0.1") female header as a socket but be aware it will stick out a lot. The end result can be seen in the image below.
This is what the final assembly will look like with the contrast potentiometer visible on the top of the board.
Connection to Arduino
Connect the I2C
Now lets connect the whole assembly to and Arduino or Arduino compatible board such as: arduSTAMP, arduCHIP and arduSTICK. The I2C bus is nice because it only uses two pins, and you can connect multiple I2C devices on the same two pins. So for example, you could connect up to 8 I2CLCDextraIO+LCDs with just two pins! These 2 pins have to be Analog 4 & 5. You can't change those pins and you can't use them for reading analog data.
For this we'll need to connnect four wires: GND, VDD, SCL (clock) and SDA (data) to the assembly. Connect the SCL pin to Analog 5 (i2c SCL pin) and SDA to Analog 4 (i2c SDA pin) of your Arduino or Arduino compatible board. Connect the VDD to +5V and GND pin to your Arduino's board ground.
Now you need to add two pull-up resistors to the bus as follows:
- Connect a 10K resistor to your Arduino Analog 5 (SCK) and another 10K resistor to your Arduino Analog 4 to 5V. Resistor configuration 5V - SDA (Analog 4) and 5V - SCK (Analog 5) as shown in the schematic below.
Please note, that if you are using the arduSTICK, these pull-up resistors are not necessary as they are already fitted in the board.
Connect the Backlight
Connect any available IO of your Arduino to the BL pin of the assembled module. We use pin 13 in our example. If you connect pin 13 to the BL pin, the examples in the LCD library will just work.
You are done, and ready to use the LCD!
Download and install the LCD library:
Open the Arduino SDK and open in the HelloWorld_i2c example in the LiquidCrystal library. If you don't see the HelloWorld_i2c example go through the process of installing the new library again, make sure you quit and restart the Arduino SDK.
Upload the sketch and configure the IO pin you have associated to the backlight. You should see the backlight turn on as the Arduino resets. If you don't see any characters, adjust the Contrast trim potentiometer with a mini-screwdriver until you see the text clearly.
If you want to have more than one LCD connected to your project, each one needs to have a unique address. You can set the I2C address by using the A0 A1 and A2 solder jumpers. By default, all jumpers are soldered to (0, 0, 0), giving an LCD module I2C address of 0x38. If you want to have an address of 0x3A you would remove the solder jumper of A1 (bit 1 of the jumper) and solder it to 1 and A2, A0 (bit 0 and 2) untouched. This will give you an address of 0x38 + "010" (in binary) = 0x3A.
You will then need to change the code:
// Jumper configuration (0 0 0) for I2C LCD address 0x38 LiquidCrystal_I2C lcd(0x38);
// Jumper configuration (0 1 0) for I2C LCD address 0x3A LiquidCrystal_I2C lcd(0x3A);
LCD Library Notes
We made a modification to the stock LiquidCrystal library so you can use it for i2c. We have made the LCD a more performant LCD library and fully compatible with the original LiquidCrystal library that can drive most Hitachi HD44780 based LCDs or compatible. The library allows for controlling LCDs using different drivers (4, 8 wire parallel interface, I2C IO port expander and Shift Regiter).
To download and install it:
- Go to the download section and get the latest release of the library.
- You will need to remove the old library, find the folder ArduinoIDE/libraries/LiquidCrystal and put it somewhere else for safekeeping.
- Uncompress the downloaded library, the folder will be called LiquidCrystal.
- Quit and restart the Arduino IDE
If you are interested in using the I2CLCDextraIO on its own, download the I2CIO library (also available when you download the LCD library) and use the expander module to get additional IOs. Please refer to the wiki page for IO pin mapping.