Arduino Playground is read-only starting December 31st, 2018. For more info please look at this Forum Post

ioBridge Serial LCD

This is the Arduino implementation for the ioBridge Serial LCD 2x16. The documentation for the this LCD is found on the ioBridge Wiki. Features include scrolling messages, animated back light control, and horizontal and vertical gauges.

Connections

The Serial LCD Screen requires Power, Ground, and Serial Signal Pin (using Pin 1 [Tx] from Arduino).

Arduino and ioBridge Serial LCD

Arduino connections to LCD Screen

Serial LCD Code

Code includes a demo of all of the features plus the library of functions used to automate features.

//
// ioBridge.com Serial LCD Demo and Functions
//

void setup() {

  // The ioBridge Serial LCD Uses a Baud Rate of 9600 on Pin 1  
  Serial.begin(9600);

}

void loop()
{ 

  // Clear LCD Screen
  clearLCD();

  // Set Background to a brightness level
  setBacklightBrightness(9);

  // Display a message from the current cursor position
  displayMessage("Serial LCD by...");

  delay(2000);

  // Move cursor then display a message
  moveCursor("02", "03");
  displayMessage("ioBridge.com");

  delay(2000);

  // Turn on and off cursor
  clearLCD();
  displayMessage("Cursor On");
  moveCursor("02", "01");
  turnCursorOn();
  delay(2000);
  moveCursor("01", "01");
  displayMessage("Cursor Off");
  moveCursor("02", "01");
  turnCursorOff();

  delay(2000);

  // Turn on and off blinking cursor
  clearLCD();
  displayMessage("Blinking Cursor On");
  moveCursor("02", "04");
  turnBlinkingCursorOn();
  delay(2000);
  moveCursor("01", "01");
  displayMessage("Blinking Cursor Off");
  moveCursor("02", "01");
  turnBlinkingCursorOff();

  delay(2000);

  // Ccroll messages on both lines
  clearLCD();
  scrollMessage(1, 8, "Scrolling Messages...");
  scrollMessage(2, 8, "GOOG: $476.10");

  delay(10000);

  // Draw horizontal gauages
  clearLCD(); 
  displayMessage("Horizontal Gauge");
  drawHorizontalGauge(2, "LO", "HI", "c");
  delay(1000);
  drawHorizontalGauge(2, "LO", "HI", "d");
  delay(1000);
  drawHorizontalGauge(2, "LO", "HI", "b");

  delay(2000);

  // Draw vertical gauges
  clearLCD(); 
  displayMessage("Vertical Gauges");
  moveCursor("02", "01");
  drawVerticalGauge(0);
  delay(100);
  drawVerticalGauge(1);
  delay(100);
  drawVerticalGauge(2);
  delay(100);
  drawVerticalGauge(3);
  delay(100);
  drawVerticalGauge(4);
  delay(100);
  drawVerticalGauge(5);
  delay(100);
  drawVerticalGauge(6);
  delay(100);
  drawVerticalGauge(7);
  delay(100);
  drawVerticalGauge(8);
  delay(100);
  drawVerticalGauge(7);
  delay(100);
  drawVerticalGauge(6);
  delay(100);
  drawVerticalGauge(5);
  delay(100);
  drawVerticalGauge(4);
  delay(100);
  drawVerticalGauge(3);
  delay(100);
  drawVerticalGauge(2);
  delay(100);
  drawVerticalGauge(1);

  delay(2000);

  // Fade backlight to brightness 1 after 2 seconds  
  clearLCD(); 
  displayMessage("-Fade Backlight-");
  setBacklightTime(1, 2);

  delay(5000);

}


//
// ioBridge Serial LCD Functions and Parameters
//

void displayMessage(char* message){
  Serial.print(message);
}

void clearLCD(){
  Serial.print(0xFE, BYTE);    
  Serial.print("Z");
}

void setBacklightBrightness(int level){
  // level
  // 0=Off -> 9=Brightest

  Serial.print(0xFE, BYTE); 
  Serial.print("B");
  Serial.print(level);
}

void setBacklightTime(int level, byte seconds){
  // level
  // 0=Off -> 9=Brightest

  // seconds
  // 01 = 1 seconds => 06 = 60 seconds

  Serial.print(0xFE, BYTE); 
  Serial.print("T");
  Serial.print(level);
  Serial.print(seconds, BYTE);
}

void moveCursorHome(){
  Serial.print(0xFE, BYTE);    
  Serial.print("H");
}

void turnCursorOn(){
  Serial.print(0xFE, BYTE);    
  Serial.print("J");
}

void turnCursorOff(){
  Serial.print(0xFE, BYTE);    
  Serial.print("K");
}

void turnBlinkingCursorOn(){
  Serial.print(0xFE, BYTE);    
  Serial.print("P");
}

void turnBlinkingCursorOff(){
  Serial.print(0xFE, BYTE);    
  Serial.print("Q");
}

void scrollMessage(int row, int speed, char* message){
  // row
  // 1=First Line -> 2=Second Line

  // speed
  // 0=Slowest -> 9=Fastest

  Serial.print(0xFE, BYTE);    
  Serial.print("S");
  Serial.print(row);
  Serial.print(speed);
  Serial.print(message);
  Serial.print(0xFE, BYTE); 
}

void moveCursor(char* row, char* column){
  // row
  // 01=First Line -> 02=Second Line

  // column
  // 01=First Position -> 16=Last Position

  Serial.print(0xFE, BYTE);    
  Serial.print("L");
  Serial.print(row);
  Serial.print(column); 
}

void drawHorizontalGauge(int row, char* leftLabel, char* rightLabel, char* length){
  // row
  // 1=First Line -> 2=Second Line

  // leftLabel and rightLabel
  // 2 character labels

  // length
  // a=Empty -> k=Full (filled in from left to right)

  Serial.print(0xFE, BYTE);    
  Serial.print("G");
  Serial.print(row);
  Serial.print(leftLabel);
  Serial.print(rightLabel); 
  Serial.print(length); 
}

void drawVerticalGauge(int height){
  // height
  // 0=Bottom -> 8=Top (filled in from bottom to top)

  Serial.print(0xFE, BYTE);    
  Serial.print("V");
  Serial.print(height);  

}