How to create custom characters on 16×2 LCD using 8051

By | June 29, 2015

 

8051 custom characters on LCD – Block diagram

8051 custom characters on LCD – Block diagram

8051 custom characters on LCD – Code

/*
* Project : LCD interfacing with 8051 Microcontroller
* Description : Special symbols display on 16x2
*               LCD using 8051 Microcontroller
*
* Software : Keil uVison4
* MCU : AT89S51/S52
* Oscillator : 11.0592 Mhz
* Date : 11-06-2015
*/

#include <reg51.h>

sbit rs = P3^2;
sbit rw = P3^3;
sbit en = P3^4;

void Delay(int i)
{
int j;
for(;i;i--)
for(j=122;j;j--);
}

void Data_Lcd (unsigned char Dat)
{
P1 = Dat;

rs = 1;
rw = 0;

en = 1;
Delay(50);
en = 0;
}
void Str_Lcd (unsigned char *Ptr)
{
while(*Ptr)
Data_Lcd(*Ptr++);
}

void Cmd_Lcd (unsigned char Cmd)
{
P1=Cmd;

rs = 0;
rw = 0;

en = 1;
Delay(50);
en = 0;
}

void Init_Lcd ()
{
Cmd_Lcd (0x38);
Cmd_Lcd (0x01);
Cmd_Lcd (0x0e);
Cmd_Lcd (0x0c);
Cmd_Lcd (0x80);
}

void Love_Lcd(unsigned char pos)
{
Cmd_Lcd(64);

Data_Lcd(0);
Data_Lcd(0x0A);
Data_Lcd(0x15);
Data_Lcd(0x15);
Data_Lcd(0x11);
Data_Lcd(0x0A);
Data_Lcd(0x4);
Data_Lcd(0);

Cmd_Lcd(pos);
Data_Lcd(0);
}

void Smile_Lcd(unsigned char pos)
{
Cmd_Lcd(80);

Data_Lcd(0);
Data_Lcd(0x00);
Data_Lcd(0x0A);
Data_Lcd(0x00);
Data_Lcd(0x00);
Data_Lcd(0x11);
Data_Lcd(0xE);

Cmd_Lcd(pos);
Data_Lcd(2);
}

void Human_Lcd(unsigned char pos)
{
Cmd_Lcd(72);

Data_Lcd(0x0E);
Data_Lcd(0x11);
Data_Lcd(0x0E);
Data_Lcd(0x04);
Data_Lcd(0x1F);
Data_Lcd(0x04);
Data_Lcd(0x1B);

Cmd_Lcd(pos);
Data_Lcd(1);
}

void main()
{
Init_Lcd ();
Str_Lcd ("EmbeddedForU.com");
Human_Lcd(0xc4);
Human_Lcd(0xCC);

Cmd_Lcd(0xc5);
Str_Lcd ("---");
Love_Lcd(0xc8);
Data_Lcd('-');
Data_Lcd('-');
Data_Lcd('>');

Smile_Lcd(0xc0);
Smile_Lcd(0xcF);

while(1)
{
Cmd_Lcd(0xc8);
Data_Lcd(' ');
Delay(500);
Love_Lcd(0xc8);
Delay(500);
}
}

 

8051 custom characters on LCD – Circuit

8051 custom characters on LCD – Circuit

8051 custom characters on LCD – output image

8051 custom characters on LCD – output image

8051 custom characters on LCD – Video

Leave a Reply

Your email address will not be published. Required fields are marked *