Graphic LCD 128x64 STN LED Backlight

I'm swimming outside my depth here.

I really need some help on interfacing this lcd with my arduino. http://www.sparkfun.com/commerce/product_info.php?products_id=710

it is based on the KS0108B chip, but I cann't find useful information on it. The datasheet is cryptic at best. Any help would be appreciated.

Jarrett

I wonder if the guy that wrote that datasheet felt bad about lying on his resume?

Without getting fancy you are going to need a lot of pins. You will want 8 pins for the DB0-7 lines, 2 for CS1 and CS2, and one each for E, RS, and R/W. The backlight power supply voltage concerns me. 4.2V. Put a diode between the 5v line and the backlight to drop the voltage a bit and hopefully be in spec.

The read and write cycle timings are fairly straightforward, I think this little pseudo code would keep you in spec...

Initialize E high and keep it there unless in a read or write.

Write Cycle:
  Set R/W low
  Set CS1 or 2 depending which IC you are writing
  Set RS and DB0-7 according to the function table
  Set E low
  Set E high
  Set E low
  Turn off Both CS1 and CS2
  Set E high

Read Cycle:
  Set R/W high
  Set CS1 or 2 depending which IC you are reading
  Set RS according to the function table
  Set E low
  Set E high
  Read the data pins
  Set E low
  Turn off Both CS1 and CS2
  Set E high

Once you have code for those two functions then you can look at the Display Control Instruction table and start trying some of the simple ones.

The sparkfun forums have a number of threads on using this module. http://forum.sparkfun.com/viewtopic.php?t=4772 is a good start. Especially note the section about a negative voltage for adjusting contrast.

I wonder if the guy that wrote that datasheet felt bad about lying on his resume?

Probably not… I have seen his work everywhere, so I think he’s steadily employed :slight_smile:

I thought my coding had failed. It may still have. I am realizing I think it may be my use of the contrast control V0 and VEE. I cann't figure out what they should be based on the data sheet. I cann't get anything to show up on the screen.

I have a question but since I am VERY NEW to this, how do I ask for help? THANKS! Tony

I have a question but since I am VERY NEW to this, how do I ask for help?

You just did.

Keep in mind that the more details you provide, and the more specific the question, the better the answer(s) will be.

If you look what I have so far, all works OK. But when I try to use the “GLCD.InvertRect (0, (8*row) -1, 127,8);” I use a push-button to move up/down (if I leave the “-1” out, all works OK but the INVERT does not look the way I would like); **If I include the “-1” my LCD display freezes .**I know that I am very new to this, so please be nice to me and tell me exactly where do I need to fix it ;). THANKS TO ALL!
Here is what I have:

/*

  • Must include Arduino KS0108 GLCD library.
  • =========================================
    */

#include <ks0108.h>
#include “Arial14.h” // proportional font
#include “SystemFont5x7.h” // system font
#include “ks0108_Arduino.h”

unsigned long startMillis;
unsigned int loops = 0;
unsigned int iter = 0;
int currentRow = 1; // 0=first row (title), 1=first menu item
int firstSensor = 0; // first analog sensor

void setup(){
GLCD.Init(NON_INVERTED); // initialise the library, non inverted writes pixels onto a clear screen
GLCD.ClearScreen();
GLCD.SelectFont(System5x7); // switch to fixed width system font
GLCD.ClearScreen();

DrawMainMenu();
}

void DrawMainMenu()
{
GLCD.SelectFont(System5x7); // you can also make your own fonts, see playground for details

DrawText(0, " NIKON Control Center");

DrawMenuLines();

InvertText(currentRow);
}

void DrawMenuLines()
{
DrawText(1, " 1)Time Capture");
DrawText(2, " 2)Lightning Capture");
DrawText(3, " 3)Time Lapse");
DrawText(4, " 4)Sound Trigger");
DrawText(5, " 5)Light Trigger");
DrawText(6, " 6)Sensor Trigger");
DrawText(7, " 7)X Sensor Trigger");

}

void DrawText(byte row, char* theText)
{
GLCD.CursorTo(0,row);
GLCD.Puts(theText);
}

void InvertText(byte row)
{

GLCD.InvertRect(0,(8*row)-1, 127,8);

}

void countdown(int count){
while(count–){ // do countdown
GLCD.CursorTo(0,1); // first column, second row (offset is from 0)
GLCD.PutChar(count + ‘0’);
delay(1000);
}
}

void ReadValue(int val)
{
int mapped = -1; //map(val, 0,860, 0,4);
if (val < 830) mapped = 1;
if (val < 800) mapped = 2;
if (val < 700) mapped = 3;
if (val < 600) mapped = 4;
if (val < 400) mapped = 5;

if (mapped != -1)
{
InvertText( currentRow );

if (mapped == 1) currentRow++;
if (mapped == 2) currentRow–;

InvertText( currentRow );
delay(500);
}
}

void loop(){ // run over and over again
firstSensor = analogRead(5);
ReadValue(firstSensor);

}

You've left out quite a few details.

For instance, there is apparently something attached to analog pin 5. You didn't tell us what.

If I include the "-1" my LCD display freezes

What does this mean? Does your screen get very cold?

I use a push-button to move up/down

Where do you read that push button?

if I leave the "-1" out, all works OK

So, then, leave it out...

but the INVERT does not look the way I would like

Seems a real shame that we can't see your screen, so we can't see what it looks like, and we have no idea what you would prefer that it look like.

Have you tried re-drawing the text after the InvertRect call? Not that I know whether that is necessary, since I don't have one of these LCDs.

I am sorry if I was not as clear as I would like to be (English is my 7th language, sorry). What I am asking for is about the command called: GLCD.InvertRect(0,(8*row)-1, 127,8); I think I have the rest of the code OK (I could use help in many areas, one is: do I need to put some kind of LIMITS in case of the LCD's memory or overflow...etc), but where I do need help also is HOW TO USE THE GLCD.InvertRect command that does not crash the LCD display. I would like to include the picture, but I do not know how to do that in this forum. So I can't demonstrate the problem. But if you just try to use the GLCD.InvertRect(0,(8*row)-1, 127,8); and see that it has a nice 1 pixel larger area around my text - that works. But as soon I go to the next line up/down and next line... as soon I reach the top or the bottom of the LCD display, the program no longer functions at all (it no longer lets me go up or down). The button I use to go up or down no longer works. As I stated in my previous message, if I REMOVE the "-1" (I loose the extra 1 pixel above the text) but the command GLCD.InvertRect(0,(8*row), 127,8); works and I can go beyond the bottom or top, even several lines beyond the top or bottom line (that I can't see, but when I count, I can count than backwards with my up/down button) and it returns to my VISABLE LCD and works just fine. So when you say :"so what...", it is just much nicer and easier to read and secondly, I like to be able to do that - I am sure many of you agree, I hope. I would like to hear from some of you that have this display and or experience using the LCD 128x64 who can point me the right direction. I THANK YOU ALL FOR YOUR HELP! Tony