Friday, June 5, 2015

Driving multiple displays with the Arduino

Over the four months or so since I got my Arduino, I have purchased several different small displays that utilize various hardware control methods: A 16x2 character LCD module that uses the Hitachi HD44780 parallel interface, a 20x4 character LCD module with an I2C board connected to its internal HD44780 interface, a Nokia 5110 84x48 LCD dot-matrix display module, and a tiny 0.96 inch 128x64 OLED display module. Both the Nokia and the OLED displays use the SPI interface. I have used these displays individually in any number or projects I have built, but I often wondered if they could all be connected and controlled at once.

One of the greatest things to me about the Arduino is its ability to accept input and provide output to an amazing variety of devices. The Uno, equipped with 14 digital I/O pins and six analog pins, make connecting with almost anything you can imagine extremely simple, and often with little or no support hardware. In addition, the SPI.h and wire.h libraries make connecting and communicating with SPI and I2C devices even easier.

I am fascinated with all the gadgets that can be interfaced with the Arduino, and when I purchased a tiny I2C Temperature and Pressure sensor, I thought it would be a perfect opportunity to see if all my displays could be connected simultaneously and be used to display atmospheric data measured by the module.
Since the larger of my two LCD character based displays is controlled via I2C, connecting it with the temp/pressure module was a snap. No additional pins beyond the four I already had connected to the sensor were needed, since I2C devices communicate on a serial bus, each device with its own address.

The two SPI displays, the Nokia and OLED used an additional five pins, three pins common between the two displays, and one pin each to control each individual display.

The parallel interface equipped 16x2 display required an additional six pins along with a separate solderless breadboard to accommodate the pins that needed to be held high or low, provide a connection for the 10k pot used to control contrast, and power the display's backlight.

All told, fifteen of the Arduino's pins. Two for ground and +5V, two of the analog I/O pins for the I2C interface, and eleven of the digital I/O pins: five for the two SPI displays, and six for the parallel display. Not too terrible when you consider that there are five discrete devices being driven!

I had a lot of fun putting the project together, along with learning to use the U8glib graphic library to display the graphical pressure data on the two individual dot addressable displays. I'm not going to post the source code here, but if anyone is interested, leave a comment and I will be happy to provide it to you.


 Until next time, happy project building, and be sure to check out some of my other projects on my YouTube channel: My YouTube Channel