Jump to content
chain

help changing LCD baud rate

Recommended Posts

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 ?

Share this post


Link to post
Share on other sites

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

 

 #include 

#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()
{
}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×