Arduino with Sparkfun 16x2 Serial LCD

Hi there,

I am currently just playing with an LCD and arduino and have used this code (below) to just get some text on the screen but am struggling to get some of the symbols that are shown in the datasheet (http://www.sparkfun.com/datasheets/LCD/GDM1602K-Extended.pdf) Page 9.

My current code is:

void setup()
{
  Serial.begin(9600);
  backlightOn();
}

void loop()
{  
  selectLineOne();
  delay(100);
  Serial.print("hi");
  selectLineTwo();
  delay(100);
  Serial.print("Hi");
  delay(100);
}

void selectLineOne(){  //puts the cursor at line 0 char 0.
  Serial.print(0xFE, BYTE);   //command flag
  Serial.print(128, BYTE);    //position
}
void selectLineTwo(){  //puts the cursor at line 0 char 0.
  Serial.print(0xFE, BYTE);   //command flag
  Serial.print(192, BYTE);    //position
}
void goTo(int position) { //position = line 1: 0-15, line 2: 16-31, 31+ defaults back to 0
  if (position<16){ 
    Serial.print(0xFE, BYTE);   //command flag
    Serial.print((position+128), BYTE);    //position
  }
  else if (position<32){
    Serial.print(0xFE, BYTE);   //command flag
    Serial.print((position+48+128), BYTE);    //position 
  } 
  else { 
    goTo(0); 
  }
}

void clearLCD(){
  Serial.print(0xFE, BYTE);   //command flag
  Serial.print(0x01, BYTE);   //clear command.
}
void backlightOn(){  //turns on the backlight
  Serial.print(0x7C, BYTE);   //command flag for backlight stuff
  Serial.print(157, BYTE);    //light level.
}
void backlightOff(){  //turns off the backlight
  Serial.print(0x7C, BYTE);   //command flag for backlight stuff
  Serial.print(128, BYTE);     //light level for off.
}
void serCommand(){   //a general function to call the command flag for issuing all other commands   
  Serial.print(0xFE, BYTE);
}

and its displays Hi Hi.

I just want half a row of the square blocks and the 2nd line to also have half a row of square blocks (fully filled in)

Can anyone help?

Thanks

So this is a serial LCD?

What library are you using if any?

ok, being a complete novice, i have no idea. how do i work it out?

I recommend looking at the "LiquidCrystal Library"-tutorials at http://arduino.cc/en/Tutorial/HomePage

These tutorials arent for Serial enabled LCD though is it the same method? really atm i just want to display a set of squares for display purposes... The code i posted above works, is this not the right method to use?

Sorry, i did not properly read the Datasheet, my fault.

I did not use serial LCDs yet, so someone else has to clear this.

Greets

apogee

do you know how to print a full square? as i showed on page 9 of the datasheet?

Serial.print(0xFF, BYTE); should do the trick :wink:

The tabe says lower part is 1111 and upper part is 1111
total 11111111 = 0XFF in hex

online converter: 8-Bit Binary Converter

Let me know if it's not working
I am planning to buy one soon

David

Perfect :slight_smile: Thankyou...

However... i was wondering, how do you get more than one on a line?

I tried to just duplicate, like so:

  delay(100);
  Serial.print(0xFF, BYTE, 0xFF, BYTE);

But it didnt like that.

Any ideas?

serial.print("[ch9632][ch9632]"); :wink:
hold alt down and punch in the ascii value of ff = 254
then release alt button. :slight_smile:

thus: alt-254 = [ch9632]

David

It doesnt seem to work, its shows up a beta symbol and if i wrote multiples, like so:

serial.print("[ch9632][ch9632][ch9632][ch9632][ch9632]");

it then starts to move and flash :s

any ideas?

Also with the alt 254, where do i do this? in arduino? as that also doesnt seem to work :s

Thanks for your help.

but with a single black square?
Serial.print("[ch9632]");

When I looked here it seemed to be a timing issue between characters:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1266353331/10

special characters seem to require 100-300 ms pause

Try to insert your string into a byte array and execute a loop printing each of the characters and a with and without delay
byte data;
byte dataArray[10];
dataArray[0] = 0x30; // 0
dataArray[1] = 0x31; // 1
dataArray[2] = 0x32; // 2
dataArray[3] = 0x33; // 3
dataArray[4] = 0x34; // 4
dataArray[5] = 0xff; // [ch9632]
dataArray[6] = 0xff; // [ch9632]
dataArray[7] = 0xff; // [ch9632]
dataArray[8] = 0x38; // 8
dataArray[9] = 0x39; // 9

or make a function to output special characters, perhaps with a variable that you can input how many copies you want of the caracter

David