Jump to content


Photo

help changing LCD baud rate


  • Please log in to reply
1 reply to this topic

#1 chain

chain

    Advanced Member

  • Members
  • PipPipPip
  • 756 posts

Posted 27 March 2015 - 02:25 AM

I have been unable to change the baud rate  in my SERLCD_16_2_5V_M43   (Connected  to Arduino)
I followed instructions in Linksprite documentation...I used the following in Setup:
void setup() {  Serial.begin(9600);Serial.write(124);
Serial.write(13);Serial.begin(2400);}
Do I need to somehow exit the command mode ?  Could you point me to a code example for changing the baud rate ?



#2 chain

chain

    Advanced Member

  • Members
  • PipPipPip
  • 756 posts

Posted 27 March 2015 - 06:42 AM

You can refer to this code example: (change baud rate to 19200)

 

 #include <SoftwareSerial.h>

#define Baud_2400    0x0b
#define Baud_4800    0x0c
#define Baud_9600    0x0d
#define Baud_14400   0x0e
#define Baud_19200   0x0f
 
#define txPin 2
SoftwareSerial LCD = SoftwareSerial(0, txPin);
// since the LCD does not send data back to the Arduino, we should only define the txPin
const int LCDdelay=10;  // conservative, 2 actually works

void SetLcdBaud(int Baud)
{
  unsigned int serialbaud;
  LCD.write(0x7C);
  LCD.write(Baud);
  switch(Baud)
  {
    case 0x0b : serialbaud = 2400;  break; 
    case 0x0c : serialbaud = 4800;  break; 
    case 0x0d : serialbaud = 9600;  break; 
    case 0x0e : serialbaud = 14400; break; 
    case 0x0f : serialbaud = 19200; break; 
  }
   LCD.begin(serialbaud);
   delay(100);
}
 
// wbp: goto with row & column
void lcdPosition(int row, int col) {
  LCD.write(0xFE);   //command flag
  LCD.write((col + row*64 + 128));    //position 
  delay(LCDdelay);
}
void clearLCD(){
  LCD.write(0xFE);   //command flag
  LCD.write(0x01);   //clear command.
  delay(LCDdelay);
}
void backlightOn() {  //turns on the backlight
  LCD.write(0x7C);   //command flag for backlight stuff
  LCD.write(157);    //light level.
  delay(LCDdelay);
}
void backlightOff(){  //turns off the backlight
  LCD.write(0x7C);   //command flag for backlight stuff
  LCD.write(128);     //light level for off.
   delay(LCDdelay);
}
void serCommand(){   //a general function to call the command flag for issuing all other commands   
  LCD.write(0xFE);
}
 
void setup()
{
  pinMode(txPin, OUTPUT);
  LCD.begin(9600);
  SetLcdBaud(Baud_19200);
  delay(200);
  backlightOff() ;
  delay(1000);
  backlightOn() ;
  clearLCD();
  lcdPosition(0,0);
  LCD.print("test baud rate 19200");
}
 
void loop()
{
}





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users