Position: Index > Control Circuit >

Controlling graphical 128

2015-03-03 13:46  
Declaration:We aim to transmit more information by carrying articles . We will delete it soon, if we are involved in the problems of article content ,copyright or other problems.

HQM1286404 is pretty old graphical LCD module but it is still popular. This LCD is controlled by KS0108 lcd controller via two segment drivers. LCD backlight color is yellow-green. I think this is good choice for many projects where graphical information needed because of several reasons a€“ you can find libraries around the internet to start working in just a few minutes, also there are several tools that can be used to generate character arrays and graphics.



Hardest thing for me was to find correct wiring as datasheet I have was for next PCB revision (HQM1286405) as mine are HQM1286404so dont be mistaken as I did. Here is the correct pin-out of LCD:

1 Vcc



4-11 DB0-DB7

12 CS2

13 CS1


15 R/W

16 D/I

17 EN

18 Vee out

19 LED Anode

20 LED Kathode

And circuitpart how it is connected to my Atmega8:


You can see that Chip select pins are in reverse order, so if halves of screen are swapped, then you have to swap wires. At VEE pin should be negative voltage near -4.9V. Potentiometer through VCON pin controls LCD contrast. Reset pin can be connected directly to microcontrollers reset circuit. In my case it is separate. Backlight LED can also be adjusted with another potentiometer a€“ is not included here too.

When circuit is ready, it is time to give a try. For this I recommend to download KS0108 Library which can be found in the internet. I tried several, and only one was working correctly. Without digging to deep use it for now. Library is written pretty some time ago by Fabian Maximilian Thiele. As his site link is dead you can download it fromhere:KS0108 Library.

Good thing with this library is that it is easy to add new characters. Just download GLCDFontCreator2 and with this java program you can fetch fonts from you windows system and automatically convert them to character arrays and save them in .h format ready to include to project. Simple examples you will find in library. I added simple bitmap display function to it which allows to display 128×64 graphics. I convert bmp files to character arrays with fastlcd.zip program. This program exports to .bas file, but it is easy to change to c compatible data a€“ simply open generated file with notepad and select replace &h to 0x, then you can copy array data to c program.


Here is my example which displays simple graphics on LCD: Bitmap dispalay demo program is ready to be compiled with latest WinAVR and flashed to Atmega8 via avrdude.

Updated code with Markus library fix: GLCD5

Reprinted Url Of This Article: