Arduino and the SparkFun Serial Graphical LCD Backpack

I’m trying my hand at controlling a 128×64 pixel Graphical LCD screen (GLCD) from my little Arduino Uno.  Now, this thing uses the fairly common KS0108B parallel interface, which is great, but requires about 20 pins to control.  In order to bring this down to a more manageable level, I also bought a Sparkfun Graphic LCD Serial Backpack, which provides a nice simple serial interface.

Basic Interaction

To start off, and to ensure I’d hooked things up correctly, I use the hardware TX pin 1 on the Arduino.  This means I don’t have to worry about SoftSerial or NewSoftSerial or anything like that.

Here’s a quick sketch that resets the screen, then runs the built-in demo.  It’s probably best to temporarily disconnect the TX lead to the GLCD, otherwise all sorts of garbage will be printed out as the screen ‘sees’ the data going to the PC…

// Clear the screen and start the demo
void setup()
{
  Serial.begin(115200);
  Serial.print(0x7C, BYTE); // Command
  Serial.print(0x00, BYTE); // Clear
  Serial.print(0x7C, BYTE); // Command
  Serial.print(0x04, BYTE); // Demo
}
 
void loop()
{
}

Resetting the Baud

The GLCD backpack communicates by default at the maximum speed of 115,200, but that can be changed using a command.  Whenver I’ve set it slower for testing (I was having trouble using NewSoftSerial at max speed), the easiest way to set it back to max is simply to bash the hardware serial port when the screen boots up.

To make this simple, I created a bare sketch that just opens the serial port and whacks out bits at 115,200.  To use this:

  1. Disconnect the GLCD’s +V pin
  2. Upload the sketch
  3. The Arduino is now cheerily bashing out the letter “a” at it’s max rate
  4. Connect the GLCD’s +V pin again
  5. The GLCD will now power up, and see 115,200 bits coming at it, and switch itself to that speed

Here’s the sketch:

// Just send characters to the serial port
void setup()
{
  Serial.begin(115200);
}
 
void loop()
{
  Serial.write("a");
}

Leave a Comment

19 − 8 =


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>