GLCD KS0108 Problem

Hi. I have a glcd which I bought from Sparkfun a while back. I’m having a go at getting the example to work as shown here in the playground.
Only thing is my screen shows something sort of resembling the example.
I’ve gone around double checking my connections and by pulling each one out looking for a change.

Any help would be great. I have one half of my project sorted already.


Hmm, not quite what you wanted :slight_smile:

Why don’t you drop the example and do something simple, like drawing a rectangle?

Make your test as simple as possible… Your code might look like:

  #include <ks0108.h>  // library header

 void setup(){

void  loop(){   
GLCD.DrawRect(10,10, 50, 50, BLACK); //should draw a 50x50 rect from x=10 and y=10

if you’re still getting weirdness after that, then there may be something wrong with your display or something wrong with the library
(disclaimer: I just barely got my screen, same one, and I have not gotten it setup and working yet. The above code is not tested)

Well the good news is that your code compiles and uploads fine. Bad news, for me, is that i still get corrupt output. The resemblance of a square is there. This is bloody annoying. This is the 3rd time i've experimented with lcd's (with different chipsets each time) and each time has been similar. Incomplete or dodgy output.

This LCD has been untouched since I bought it 2 years ago (for another project which ended up using 7segs). All i've done to it is solder on some pin headers and plugged into a breadboard. Checked the wiring again. It's fine. I'm getting fed up of projects of mine being kicked in the teeth just when I get it moving.

All right, next step is to have someone else check your work :)

Post some pics of your wiring. Have you gone through your headers with a meter and made sure you don't have any shorts or anything? Maybe move it to a different location on your breadboard to see if the contacts might be bad.

If I have some time tonight I will try and wire mine up according to the example and see if I can make mine work. (I haven't gotten that far)

The panel is 2 years old... have you kept it in a static-safe bag? Possibly damaged somewhere in there? What model panel is it?

P.S. I hope you won't take that offensively. I know you've checked the wiring several times already. Maybe someone here will catch something you missed.

The resemblance of a square is there....

can you post a picture - I am guessing that the library is driving the display faster than it can manage, but it would help if I could see the output

OK. So i've moved the LCD to different section. Ripped out the wires and replaced some I thought may be a bit iffy and rewired the lot. This is what I still get with the square example.

The LCD has been in it's black (antistatic?) bag it came with since I got it except for possibly the day I got it. You'd imagine these things should be able to withstand a bit of mistreatment in any case.

How's yours going sircastor?

regomodo, I would think from display in that photo that the most likely problem is the wiring not matching the code. I have seen a number of people report that they have fixed a similar problem by correcting a wiring discrepancy only noticed after many times of checking. Its hard to confirm from your picture if your wiring is ok (you may want to lay out the wires to make it easier to where they are going and take another picture).

BTW, did you change anything in the code you are running?

I notice there are 2 wiring types for this library. I'm using ver1 which I believe is to be correct.

Problems like this i've learned are due to simple errors like incorrect wiring but I have gone over the wiring and restarted it many a time to the point I feel like giving up and just use 7-segs.

I can't see how i'd make the wiring obvious short of using a different colour for each wire. The wiring is pretty simple in any case. I'm starting to think my arduino is at fault as this is 3 different lcd's in a row that haven't worked.I'd like to get another but funds prohibit this.

Well, I thought it may be a gentoo-amd64 issue so i’ve just tried in XP. No luck there either.

Mem. No i’ve changed nothing in the code examples.

I’ve just tried this

#include <ks0108.h>

void loop(){ // run over and over again
GLCD.ClearScreen(); // clear the screen

I should have a blank LCD right? I’m getting blocky shapes instead.

Thos blocky shapes could be caused by incorrect wiring. Perhaps have someone else double check that the wires match the diagram (in my experience its easy to keep overlooking a wiring problem, I and others have been 100% certain that the wiring on some project was ok, only to find later that it was not )

Sod it. This has been doing my head in for too long. Just tried my hd44780 display with the liquidcrystal display. Yep, that doesn't work either. I've had enough of getting nowhere and have nobody electronics inclined at my disposal. In any case I am now 100% certain my wiring is correct as i've ripped it apart and gone dead slow 2 more times.

Thanks anyway.

I think I know what your problem is. I had the same problem of seeing something like what the print-out was supposed to be, but generally unreadable.

It turns out the library needs to artificially delayed so it's clock update matches with that of the LCD module.

see this forum post, it has some instructions on adding the string ' "nop\n\t" ' to the library and recompiling.


Hi Sircastor. Cheers for that link. I had seen that thread but it was huge so I wasn't up for trawling through all of it. Looks like I started at the wrong end of the thread. According to Rower he had to add 46 nop's or using the BIG_DELAY method. I haven't tried it yet but how would I go about compiling it? A couple days ago I tried compiling the file with a simple gcc -o but it complained.

Hi Regomodo,

Fortunately, recompiling is much easier than gcc'ing or anything like that. Here's the lowdown:

In the ks0108 library folder in the arduino folder, there's a file that'll be called ks0108.o Delete that file.

Open the ks0108.cpp in a regular old text editor, add the 45 nops ( "nop\n\t" ) to the delay450ns() function. There are already a few in there, so it should be fairly easy to spot.

Once you've saved that file, open up the Arduino IDE, press the 'Verify' button. This will recompile the library for use (technically, so will loading the code onto your Arduino). Load your code, and give it a shot.

A beta version of the GLCD library has been added to the playground that is more tolerant of slow displays and is easer to tweek. The download is here:

Delays (if needed) are added by changing a constant in a header file. The constant is EN_DELAY_VALUE and its in a file called ks0108_Panel.h

There is more information here:

Holy crap mem! Do you know how happy this makes me? I used the bundled example and everything looks great with an fps of 7. More than enough for me.

Cheers for the work.