My final will be a small art piece with an 8 character LCD. The LCD I will be using is this one by Newhaven Display International. It follows the HD44780 protocol, which is standard for controlling LCDs, but uses only 14 pins instead of 16, because it is not backlit and hence does not need a power and ground pin for the backlight. I will be using the 4-bit version of the HD44780 protocol, meaning 4 pins will be used to send data. In addition to these four pins, my microcontroller will need to control the "register select" and "enable" pins on the LCD, for a total of six pins of digital output. Therefore, I will need the ATTiny84, with its 13 GPIO pins, instead of the 85.
I have already breadboarded the project using an ATMega328PU (see video below). From this process I learned a few things specific to the LCD that I am using. First, that it is necessary to ground the unused data pins. Although this is a good practice in general, I did not have trouble with other LCDs when leaving the unused pins floating.
Second, I discovered by experimentation the correct settings for the V0 pin, which controls the contrast on the display. On most LCDs, this pin allows one to adjust contrast by varying the voltage supplied to it. The datasheet for my LCD claims the same, and recommends supplying 0 volts. Using a breadboard, I found the proper contrast setting by adjusting a potentiometer connect to the V0 pin. Then, I measured the voltage across the potentiometer using a multimeter, and attempted to replicate this voltage by means of a voltage divider using two fixed resistors. However, with the voltage divider the characters were always invisible. If I connected the pin to ground as recommended on the datasheet, the characters were visible, but not as sharp as they could be. Finally, on a whim, I tried matching the resistance of the potentiometer instead of the voltage. This worked - the pin seems to respond not to voltage, but to the resistance between it and ground, with the ideal contrast being set at around ~1800 Ohms.
Bill of Materials
- LCD Display: Newhaven Display NHD-0108BZ-FSY-YBW-33V3, already purchased, will buy one additional for backup.
- ATTiny84 Microcontroller
- For the V0 pin, based on what we have in the hard lab: 1kOhm + 2x 470Ohm
- 1x 10 kOhm for the Reset pin on the ATTiny84.
- 100uF for the main power.
- 0.1uF near the power pin on the ATTiny84.
- Li-Po Battery Connector for power, as this is meant to be a standalone, battery-powered device.
- Li-Po Battery x2, one to charge while the other is in use.
- 1x One-Sided PCB Blank
- 3.3V Voltage Regulator
Of these, I will need to purchase the spare LCD, the batteries, and the ATTiny84.