Pages: [1]   Go Down
Author Topic: 20x4 Serial LCD from sparkfun. Won't print 20chars  (Read 482 times)
0 Members and 1 Guest are viewing this topic.
Norway
Offline Offline
Jr. Member
**
Karma: 0
Posts: 79
<3 Arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Somehow it only prints 16 chars per line. Dunno why?



Code:
Code:
#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.
« Last Edit: November 27, 2009, 05:37:45 am by Stigern » Logged

I'm from Norway!

0
Offline Offline
Sr. Member
****
Karma: 4
Posts: 262
bluesmokelabs.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Ie lcd.begin(20,4);

?

tgw
Logged

North Yorkshire, UK
Offline Offline
Faraday Member
**
Karma: 104
Posts: 5531
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

Pages: [1]   Go Up
Jump to: