#include "reg51.h"
#include<intrins.h>
#define uchar unsigned char
sbit RS=P0^7;
sbit RW=P0^6;
sbit EN=P0^5;
void write1(unsigned char dat);
void wri(unsigned char com);
//void keyscan();
unsigned int m,n,v,k;
unsigned char tab1[]="欢迎用单片机系统";
unsigned char tab2[]="ST7920字库液晶屏";
unsigned char tab3[]="是你学习的好帮手";
unsigned char tab4[]="TEL:13078588356 ";
//*********************************************//
void delay(unsigned int ms)
{
unsigned int i, j=0;
for(i=0;i<=ms;i++)
for(j=0;j<110;j++);
}
void disp1()
{
//wri(0x80);
//delay(20);//
wri(0x80);
for(m=0;m<=16;m++)
write1(tab1[m]);
delay(5);
wri(0x90);
for(n=0;n<=16;n++)
write1(tab2[n]);
delay(5);
wri(0x88);
for(v=0;v<=16;v++)
write1(tab3[v]);
delay(5);
wri(0x98);
for(k=0;k<=16;k++)
write1(tab4[k]);
return;
}
void disp_int()
{
delay(5);
wri(0x30);
delay(5);
wri(0x0c);
delay(5);
wri(0x01);
delay(5);
wri(0x06);
delay(5);
}
void wri(unsigned char com)
{
RS=0;
RW=0;
EN=1;
P2=com;
delay(5);
EN=1;
EN=0;
}
void write1(unsigned char dat)
{
EN=1;
RS=1;
RW=0;
P2=dat;
delay(20);
EN=1;
EN=0;
}
void main()
{
disp_int();
disp1();
while(1);
}
|