sparkfun serial lcd

i'm having some trouble with the sparkfun 2,5 lcd, for some reason it's displaying wierd info...

i looked at the interfacing page on the playground, and i tried the code that was posted for this specific lcd, but the code seems flawed...

it sems that any one of the charecters that arent used are completely filled in with the black color, and for some reason it is also displaying wierd information from my potentiometer.

i gave it 2 commands... on the to line i told it to show the value of the pot, and on the bottem, i told it to show the value divided by four, and when i put the pot at highest it sais 255 on the lower part of the screen, which is correct, and 102355 on top, which is sort of correct... idk y the 55 is at the end. And when the pot is on the lowest, the bottem screen sais 073, which is incorrect, it saposed to be 0.... and the top sais 058355, also strange since it still has 55 at the end, and the working value is sapposed to be 0!

and the values inbetween are also a little crazy... here is the code:

void setup()
pinMode(0, INPUT);

void loop()

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 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);

oh yea, also, how can i use the screen without being connected to the computer, becuase it uses serial.begin........


omg, and now it's acting very strange! everytime that something is uploaded, the first charecter on the bottem line switches between the correct charecter and the letter "g" for some reason!

Maybe try clearing the LCD between line writes?

how so?

( and the g thing is gone now... )


out of curiosity, why are you setting up the RX pin as an input?


i dident touch the code, that code i got from the example on the lcd page, so the code came like that ( except for when i alter what the lcd sais )

more good news: i said before, the thing where the g wouldn't stop changing with the other letters is now fixed... 2.i was able to make the screen portable by just connecting the battery pack, and disconnecting and re connecting the actual screen ( weird how i have to disconnect and reconnect every time it goes off... ) 3. i used if statements to put a value on the lcd between 5 and 1 depending on what value the potentiometer is between ( ex pot value between 150 and 200 = lcd value, 2 )

now i have less of my original problems, but more diffrent problems;

like, how do i make the screen work without disconnecting it and reconnecting it every time i turn off the power? and how do i change words instead of numbers? i can make a number change, but i get an error when i et a value to a word, and i'm not sure how to make it change words.

wow, not bad... only 2 q's...

anybody? please...

like, how do i make the screen work without disconnecting it and reconnecting it every time i turn off the power?

ok here is one answer…

the bootloader sends data over TX during boot, so you have two options to prevent that from garbling the LCD data:

  • burn the final chip without the bootloader- just the hex code.
  • put a CD4066 or MAX4066 CMOS analog switch between the TX line and the RX line on the LCD. These “switches” can be turned on and off with an Arduino pin. Basically, it’s the digital equivalent of doing what you are doing now: plugging and unplugging the wire from the RX header.

So you would have aline in your setup like digitalWrite(5, HIGH); // this gets conected to the analog switch control pin , with pin 5 connected to the analog switch control pin. You also need a pull-down resistor on the control pin of the anlog switch- 10K will do.

See Don Lancaster’s “Getting started in Electronics”, or just Google up a schematic that uses one…
Here’s one diagram where they use a CD4066 to switch a video signal:

Oh and these analog switches have no polarity- they conduct current in both directions.


thank you for an answer!! seems it now just works by itself now, and during code upload, i ALWAYS disconnect the serial wire, because i know the damage the raw data can do to the sparkfun chip...

but that max chip would be freaken awesome to stop the annoying disconnect and recconecting!