This project shows how to drive two 20x4 LCD displays on the I2C bus on an arduino. Each display has an 80 character buffer and works as a scrolling terminal. Print a string, and it will display at the bottom of the screen and when that line is full, all the lines scroll up.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Modify the Address of One of the I2C Boards
You can buy displays with these I2C adapters soldered on the back (or buy the adapter separately for about a dollar). Old displays were at address 0x27 but the ones available in the last few years are at address 0x3F. If the address is not correct, the display won't work at all, which can be confusing if you have downloaded some code and expect it to work out of the box.
Also the displays need the pot turned to the correct contrast - the default when you buy them is nothing displayed and zero contrast. Set it so the background just starts to appear.
On the back are three little pads you can bridge, labelled A0, A1 and A2, and these allow up to 8 displays with addresses 0x38 to 0x3F. By soldering the pad on A0 the address changes from 3F to 3E.
The arduino board I have has 4 pins for the I2C bus, and SDA and SCL are also replicated on the top socket. You could build a 'daisy chain' I2C adaptor, or just use the available pins as shown in the photo.
Code is attached and using this is as simple as printLCD("Hello World",1); where the number indicates display 1 or 2. It would be possible to add more displays if needed as the only code overhead for each display is the 80 byte display buffer.