Introduction: 16x2 LCD Screen for ATtiny85, Only Two Pins

About: Jack passed away May 20, 2018 after a long battle with cancer. His Instructables site will be kept active and questions will be answered by our son-in-law, Terry Pilling. Most of Jack's instructables are tuto…

An ATtiny85 only has five data pins. There are times when you need an alphanumeric readout to display data, or for temporary use as a debugging tool, and you need to use as few pins as possible. By using one of these Arduino shields from Adafruit it is possible to drive a 16x2 LCD screen using only two pins.

You will also need:

In this picture the Arduino is only being used as a power supply.

Step 1: Assemble the Shield Kit

Assemble the shield kit, follow these instructions: https://learn.adafruit.com/rgb-lcd-shield

Step 2: Download and Install the Libraries

Download the following libraries:

The first library folder is the I2C implementation for the Attiny85. Unzip it and rename it "TinyWireM".

The second library folder is the code needed to use the shield on an Attiny85.

The third folder is the code needed to use the shield on an Arduino. Unzip it and rename it "Adafruit_RGBLCDShield".

You don't need the Adafruit_RGBLCDShield for this instructable, but since you are downloading files and installing libraries you might as well get the code to run your new shield on the Arduino.

Move all three folders into the libraries folder. The libraries folder should be in the sketchbook folder. If it is not there create it.

If you have never worked with the ATtiny85 chip you will need to install the core files and the boards.txt file. Follow this instructable to learn how to program the chip: https://www.instructables.com/id/How-To-Program-An-...

Step 3: Building the Circuit

In the diagram the red dot on the chip is the alignment dot representing physical pin one. The pink lines are covering the holes where the screen shield connects.

On the side of the shield with the buttons and the chip there are two sets of six pins. Looking at the shield with the reset button on the right there are 12 pins. We will call them 1 - 12 from left to right.

  • Pin 3 connects to the positive rail.
  • Pin 5 connects to the ground rail.
  • Pin 11 connects to digital pin 0 on the Attiny85.
  • Pin 12 connects to digital pin 2 on the Attiny85.

Build the circuit following the diagram.

Step 4: The Demonstration Program

Start the Arduino IDE and copy/paste this program into it. Upload the program to the Attiny85.

/*********************************************************************
 * Filename LCDdemo.ino
 *
 * Print "Hello World!" on the first line, 
 * then count seconds on the second line.
 *
 * On the side of the shield with the buttons and the chip there are
 * two sets of six pins.  Looking  at the shield with the reset button
 * on the right there are 12 pins. We will call them 1 - 12 from left to right.
 * Pin 3 connects to the positive rail.
 * Pin 5 connects to the ground rail.
 * Pin 11 connects to digital pin 0 on the Attiny85.
 * Pin 12 connects to digital pin 2 on the Attiny85.
 *
 ********************************************************************/

#include <TinyWireM.h>                 // ATtiny I2C communication
#include <TinyAdafruit_RGBLCDShield.h> // RGB LCD Shield communications

Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();

long secs = 0;

void setup()
{
  lcd.begin(16, 2); // set up the LCD's number of columns and rows.
  lcd.setBacklight(7); // For monochrome LCD lcd.setBacklight(ON)
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Hello World!");
}

void loop()
{
  lcd.setCursor(0,1);
  lcd.print(secs);
  delay(1000);
  secs++;
}

The line of code that says "lcd.setBacklight(7);" is for an RGB LCD. You can use the numbers 1 - 7 to set the backilght to different colors. If you are using a monochrome screen use "lcd.setBacklight(ON);".