2 Line LCD Display

Since moving away from using an Arduino for projects and using microcontrollers directly, I’ve lost the nice facility the Arduino has for sending debug information out the USART to the PC for display.  It’s also very easy to connect to the Arduino to the PC for programming, since it is simply a USB connection.

I decided to build a little circuit board which contained a 16 character by 2 line display based on the HD44780 chipset.  This is normally a parallel device taking at least 6 pins to operate (10 in 8 bit mode), but my first project I was going to use the 16×2 LCD display was based on a ATTiny85 processor (8 pins total on the device), so I had to roll my own serial interface for the device.  I decided to use an SPI interface, which had the added benefit that once I connected my debugging display to the SPI interface, I already had connections to the pins used by the TinyUSB programmer, so I was able to kill 2 birds with on stone; interface a debugging display and a programmer with a minimal set of breadboard wires.

LCD Breadboard Debugging Tool

LCD Breadboard Debugging Tool

The circuit is very simple, with a 74LS595 Shift Register converting the serial data transmitted through the MOSI pin of the AVR chip, clocked by the SCK pin, and latched to the output through the SS pin.

LCD Debugger Schematic

LCD Debugger Schematic

The board also includes pots for contrast and brightness of the LCD display, a reset switch, and the connector for the programmer.

The software to drive the display borrows heavily from this blog which describes interfacing this display to a PIC microcontroller.  The code is fairly straightforward; you need to define the pins for the MOSI, SCK, and shift register latch, and then you can start LCDSendString’s to the display.  Since the ATTiny85 does not have API, a bit-banged version of the code is included within the proper #if defined blocks.  The code is located on GitHub here: https://github.com/kevinkessler/LCD2Line

Sample code to use the display would look like:

#include "LCD2Line.h"

int main (void)
    LCDSetDisplay(1,0,0);  // Turn on display, Turn off cursor
    LCDSetDDramAddr(0x00); // Sets display to 1st character on the 
                           // first line
    LCDSetDDramAddr(0x40); // Set display to 1st character on the 
                           // second line