LCD:creating custom character

this tutorial gives you best explanation of displaying any character on 16*2 lcd on 5*8 pixel irrespective of ASCII value. almost all lcds have HD44780U controller built in them. it is recommended to read this article prior to proceed further. lcd has CGRAM where we can write for custom character and then can easily be extracted to display on lcd

PROTEUS DESIGN

all connections are similar as we did in earlier classes of LCD

Generating Custom Character

i am going to explain you how can you make  a symbol of your choice. we'll learn the concept by simply creating a heart on LCD. working on commonly used use 5*8 pixel display we would make a 5*8 matrix.first fill the cell corresponding to desire character as you can see in following figure

EasyCapture1 EasyCapture2EasyCapture1EasyCapture1EasyCapture2                                       

CODE

according to cell you just filled in above matrix table ,make an array for heart in code. value of first row in matrix is 0x01(00001010),similarly value of second row is 0x15(00010101) and so on....it is not required to fill cell of each row if you leave the last row uncolored it only reduce the size of character displayed on LCD

before proceeding further you must have knowledge of CGRAM(memory space for generating special character) you need to read LCD article. it is assumed you know how to display character on LCD.

function lcdcmd(0x40) point to first address of CGRAM where you can send the data for heart symbol. you can generate many character by pointing to 0x48,0x56..... address of CGRAM. to read character you have created earlier at 0x40   send command 0x00 to lcd. To extract data at 0x48,0x56... use command 0x01,0x02....respectively. you can also extract the same character multiple times just by sending command to read it from CGRAM location.

complete code

#include<reg51.h>
#define lcdport P2
sbit rs=P3^0;
sbit en=P3^2;
sbit rw=P3^1;
void lcdcmd(char);
void lcdint();
void lcddata(char);
void lcdstring(char *);
void delay(unsigned int);
unsigned char symbol1[8]={0x08,0x04,0x02,0x1f,0x02,0x04,0x08,0x00};     //heart symbol
unsigned char symbol2[8]={0x0a,0x15,0x15,0x15,0x11,0x11,0x0a,0x04};    // vartical arrow
int i;
void main()
{
lcdport=0x00;                                                  
lcdint();
lcdstring("R");
lcddata(' ');
lcdcmd(0x40);//Address where first custom character is stored
for(i=0;i<8;i++)
{
lcddata(symbol1[i]);
}
lcdcmd(0x82);//Address on lcd where the character is to be displayed
lcddata(0x00);// Display the character created at address 0x40
lcdcmd(0x48);
for(i=0;i<8;i++)
{
lcddata(symbol2[i]);
}
lcdcmd(0x83);  
lcddata(0x01);
lcdcmd(0x84);
lcddata(0x00);
lcddata(' ');
lcdstring("H");
delay(50000);
}
void delay(unsigned int x)
{
 unsigned int i;
 for(i=0;i<x;i++);
}
void lcdint()
{
  lcdcmd(0x38);
  delay(500);
  lcdcmd(0x01);
  delay(500);
  lcdcmd(0x0c);
  delay(500);
  lcdcmd(0x80);
  delay(500);
  lcdcmd(0x0e);
  delay(500);
}
void lcdcmd(char value)
{
  lcdport = value;
  rw=0;
  rs=0;
  en=1;
  delay(500);
  en=0;
}
void lcdstring(char *p)
{
  while(*p!='\0')
   {
     lcddata(*p);
     delay(2000);
     p++;
   }
}
void lcddata(char value)
{
  lcdport = value;
  rs=1;
  rw=0;
  en=1; 
  delay(500);
  en=0;
}

VIDEO

Category: 

tags: 

Share

Who's new

  • ravirajpatil871...
  • shubhambajoria
  • yassir
  • demiholyman890954
  • scottgillum51169040

Get Notified

 

Share

We are Social

Syndicate

Subscribe to Syndicate