I bought me a cheap 128×64 graphic lcd on Ebay, cost me less then 7€ including shipping. It didn’t come with a datasheet or any instructions. After some googling, reading lots of websites and trying out a couple of different Arduino libraries I got it to work 🙂
I first needed to find out how to connect it to an Arduino. The glcd has no brand printed on it, there is just a type number printed on the back, 12864zw. Google came up with a datasheet from a Digole ST7920 LCD. This gave me a bit more information on how this thing works. The ST7920 chip supports parallel and synchronized serial interface (SPI) mode. You can choose which mode to use by setting the PSB pin high or low.
I first tried to get the lcd to work with the glcd Arduino library. This library uses the parallel mode to communicate with the lcd. You need most of the pins of an ATmega328 when using this mode. I could not get my lcd to work with the library. Maybe I made some mistake in the wiring.
I then switched to the U8glib and had some more luck. This library supports the parallel and SPI mode. I first tried the parallel mode and got it working. Then I used the hardware SPI mode of the Arduino to control the lcd. Using this mode you need only 3 pins (SCK, MOSI and CS) on the Arduino to control the lcd. This is how I connected the lcd to the Arduino:
On some lcd’s you need to connect the 5V to the blacklight through a resistor. My lcd seems to have those resistors on the PCB. I measured 20ohms between the BLK pin and the K pad (on the back of the board) and also between the BLA pin and the A pad.
Regulating the contrast of the lcd is normally done with a potentiometer. On the back of the PCB there are 3 pads for a potentiometer, unfortunately the potentiometer is not fitted to the board of my lcd. I tried using an external potentiometer by connecting one (outer) leg of the potentiometer to gnd, the middle pin of the pot to the Vo pin and the other leg of the pot to the Vout pin of the lcd. But it did not work, there are a couple of resistors/jumpers on the back of the pcb which make it impossible to make it work. Luckily the contrast seems to be fine with the current setup without the potentiometer.
The lcd also has a reset pin (RST), you can connect this to the reset pin of the Arduino. In my case it made it impossible to upload sketches to the Arduino with the reset pin connected. So I just left it unconnected, it doesn’t seem to make a difference to the lcd.
I tried the different example sketches that come with the U8glib library. In the beginning of the sketch you must create an u8g object. When using the hardware SPI port of the Arduino you only need to define the chipselect (CS) pin like this: U8GLIB_ST7920_128X64_1X u8g(10);
Now I only need to figure out how to display nice graphics on the lcd 🙂