rowan_mcalpin
Published © GPL3+

Procedural Text Printing on LCD Display

Print fully customizable 2 line letter by letter onto an LCD 16x2 display with an Arduino.

BeginnerFull instructions provided1,026
Procedural Text Printing on LCD Display

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
You can also use any Arduino you have around the workshop
×1
Jumper wires (generic)
Jumper wires (generic)
×16
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×1
Standard LCD - 16x2 White on Blue
Adafruit Standard LCD - 16x2 White on Blue
×1

Story

Read more

Schematics

Schematic

Code

The Code

Arduino
#include <LiquidCrystal.h>

const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

// CHANGE THESE TO CUSTOMIZE
char firstLine[] = "TOP LINE"; // TO CHANGE THE FIRST LINE, CHANGE WHAT'S IN THE QUOTATION MARKS
char secondLine[] = "BOTTOM LINE"; // TO CHANGE THE SECOND LINE, CHANGE WHATS IN THE QUOTATION MARKS

int firstLineLen = strlen(firstLine);
int len = strlen(secondLine);
void printMessage() {
  if (firstLineLen < 16) {
    for (int f = 0; f < firstLineLen; f++) {
      lcd.setCursor(f,0);
      lcd.print(firstLine[f]);
      delay(150);
    }
  } else {
    for (int g=0; g<13; g++) {
      lcd.setCursor(g, 0);
      lcd.print(firstLine[g]);
      delay(150);
    }
    for (int h=13; h<16; h++) {
      lcd.setCursor(h, 0);
      lcd.print(".");
      delay(50);
    }
  }
  if (len < 16) {
    for (int i=0; i < len; i++) {
      lcd.setCursor(i,1);
      lcd.print(secondLine[i]);
      delay(150);
    }
  } else {
    for (int j=0; j<13; j++) {
      lcd.setCursor(j, 1);
      lcd.print(secondLine[j]);
      delay(150);
    }
    for (int k=13; k<15; k++) {
      lcd.setCursor(k, 1);
      lcd.print(".");
      delay(50);
    }
  }
}

void setup() {
  lcd.begin(16, 2);
  printMessage();
}

void loop() {
}

Credits

rowan_mcalpin

rowan_mcalpin

2 projects • 0 followers

Comments