How to get charcters on the screen

The LCD and Keypad Shield gives you a handy 16-character by 2-line display, 5 buttons and a controllable backlight.
Post Reply
Davo9064
Posts: 2
Joined: Sun Nov 08, 2015 4:51 am

How to get charcters on the screen

Post by Davo9064 » Sun Nov 08, 2015 4:57 am

I am trying to get smiley faces and other symbols to appear on the screen but I have had no luck. I have tried a couple of different codes not I am having no luck. I am using a older version of the UNO board.

andrew
Freetronics Staff
Freetronics Staff
Posts: 978
Joined: Sun Jul 14, 2013 7:06 am
Location: Melbourne, Australia
Contact:

Re: How to get charcters on the screen

Post by andrew » Sun Nov 08, 2015 6:53 am

Example sketch from:
http://tronixstuff.com/2011/01/08/tutor ... rome-lcds/

It defines three custom characters, each of which are made up of seven rows of five pixels.
You can change which pixel turns on and off by altering the byte variables. 1 is on, 0 is off.

Code: Select all

// Example 24.2
 
#include <LiquidCrystal.h> // we need this library for the LCD commands
 
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(4,5,6,7,8,9); // define our LCD and which pins to use
 
int d = 3000; // used for display delay
byte a[8] = {  
  B00000,  B00000,  B00000,  B00100,  B00100,    B00000,  B00000,  B00000};
byte b[8] = {  
  B00000,  B00000,  B10001,  B10001,  B10001,  B10001,  B00000,  B00000};
byte c[8] = {  
  B11111,  B10001,  B10001,  B10001,  B10001,  B10001,  B10001,  B11111};
 
void setup()
{
  lcd.createChar(0,a); // define our characters into the sketch as variables
  lcd.createChar(1,b);
  lcd.createChar(2,c);
  lcd.begin(16, 2); // need to specify how many columns and rows are in the LCD unit
  lcd.clear();      // this clears the LCD. You can use this at any time
}
 
void loop()
{
  for (int z=0; z<16; z++)
  {
    lcd.setCursor(z,0);
    lcd.write(0);  // write the first character
    delay(250);
    lcd.setCursor(z,0);
    lcd.write(1);  // write the second character
    delay(250);
    lcd.setCursor(z,0);
    lcd.write(2);  // write the third character
    delay(250);
    lcd.setCursor(z,0);
    lcd.write(1); // write the second character
    delay(250);
    lcd.setCursor(z,0);
    lcd.write(0);  // write the first character
    delay(250);
  }
  delay(1000);
  lcd.clear();
}

Davo9064
Posts: 2
Joined: Sun Nov 08, 2015 4:51 am

Re: How to get charcters on the screen

Post by Davo9064 » Tue Nov 10, 2015 10:16 am

Thanks for your help.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests