Go Down

Topic: 20x4 Serial LCD from sparkfun. Won't print 20chars (Read 620 times) previous topic - next topic

Stigern

Nov 27, 2009, 11:28 am Last Edit: Nov 27, 2009, 11:37 am by Stigern Reason: 1
Somehow it only prints 16 chars per line. Dunno why?



Code:
Code: [Select]

#include <NewSoftSerial.h>
NewSoftSerial mySerial(7, 8);

void setup()
{
 mySerial.begin(9600);
}

void loop() {
 // Example usage:
 clearLCD();
 backlightOn();
 //Print text on each line
 selectLineOne();
 delay(100);
 mySerial.print("AAAAAAAAAAAAAAAAAAAA");
 delay(10000);

}
//SerialLCD Functions
void selectLineOne(){  //puts the cursor at line 0 char 0.
 mySerial.print(0xFE, BYTE);   //command flag
 mySerial.print(128, BYTE);    //position
}
void selectLineTwo(){  //puts the cursor at line 2 char 0.
 mySerial.print(0xFE, BYTE);   //command flag
 mySerial.print(192, BYTE);    //position
}
void selectLineThree(){  //puts the cursor at line 3 char 0.
 mySerial.print(0xFE, BYTE);   //command flag
 mySerial.print(148, BYTE);    //position
}
void selectLineFour(){  //puts the cursor at line 4 char 0.
 mySerial.print(0xFE, BYTE);   //command flag
 mySerial.print(212, BYTE);    //position
}

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




And! how come this 20x4 needs some delay? Or else it won't show anything. The 16x2 lcd I got just prints it without the need for a delay.
I'm from Norway!

thegeekway

Im not familiar with that particular library, but does it need to be defined like in LiquidCrystal:

Ie lcd.begin(20,4);

?

tgw

mowcius

Quote
Im not familiar with that particular library, but does it need to be defined like in LiquidCrystal:

Ie lcd.begin(20,4);

Nope, just needs to be sent serial commands.

You display backpack is probably set up for the wrong type of display.
See this for info on how to set it up right:
http://www.sparkfun.com/datasheets/LCD/SerLCD_V2_5.PDF

Mowcius


Go Up