LM1602液晶显示程序
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
LCD_Printfc(2,9,':');
LCD_Printfc(2,10,second/10+'0');
LCD_Printfc(2,11,second%10+'0');
}
void Time0_Init(void)
{
TMOD = 0x01;
IE= 0x82;
TH0 = 0x4c;
TL0 = 0x00;
ucharminite= 11;
ucharhour = 15;
sbitRS = P2^5;
sbit RW = P2^6;
sbit E = P2^7;
void delay()
{
inti,j;
for(i=0;i<=100;i++)
for(j=0; j<=20; j++);
}
voidWrite_Command(ucharcommand)
Write_Command(0x38);
Write_Command(0x0c);
Write_Command(0x06);
}
void LCD_Printfc(uchar hang,uchar lie,uchar sign)
{
uchara;
if(hang == 1) a = 0x80;
if(hang == 2) a = 0xc0;
{
P0 来自百度文库 command;
RS = 0;
RW = 0;
E = 1;
delay();
E = 0;
}
voidWrite_Data(ucharData)
{
P0 = Data;
RS = 1;
RW = 0;
E = 1;
delay();
E = 0;
}
voidLCD_Init(void)//初始化
{
Write_Command(0x01);
while(1)
{
LCD_Display(tab1);
time_view();
}
}
TR0 = 1;
}
void Time0_Int() interrupt 1
{
ucharcount;
TH0 = 0x4c;
TL0 = 0x00;
count++;
if(count == 20)
{
count = 0;
second++;
}
}
void main(void)
{
LCD_Init();
Time0_Init();
for(i=0;i<16;i++)
{
Write_Data(tab2[i]);
delay();
}*/
}
voidtime_view(void)
{
if(second == 60)
{
minite++;
second = 0;
}
if(minite== 60)
{
hour++;
minite= 0;
}
if(hour == 24)
{
hour = 0;
}
LCD_Printfc(2,4,hour/10+'0');
LCD_Printfc(2,5,hour%10+'0');
LCD_Printfc(2,6,':');
LCD_Printfc(2,7,minite/10+'0');
LCD_Printfc(2,8,minite%10+'0');
a = a + lie;
Write_Command(a);
Write_Data(sign);
}
voidLCD_Display(uchar*tab1)
{
uchari;
Write_Command(0x80);
for(i=0;i<16;i++)
{
Write_Data(tab1[i]);
delay();
}
/*Write_Command(0xc0);
#include<reg52.h>
#defineucharunsigned char
#defineuintunsignedint
unsigned char code tab1[16]=" Now time is: ";
unsigned char tab2[16]=" 00:00:00 ";
ucharsecond = 30;
LCD_Printfc(2,10,second/10+'0');
LCD_Printfc(2,11,second%10+'0');
}
void Time0_Init(void)
{
TMOD = 0x01;
IE= 0x82;
TH0 = 0x4c;
TL0 = 0x00;
ucharminite= 11;
ucharhour = 15;
sbitRS = P2^5;
sbit RW = P2^6;
sbit E = P2^7;
void delay()
{
inti,j;
for(i=0;i<=100;i++)
for(j=0; j<=20; j++);
}
voidWrite_Command(ucharcommand)
Write_Command(0x38);
Write_Command(0x0c);
Write_Command(0x06);
}
void LCD_Printfc(uchar hang,uchar lie,uchar sign)
{
uchara;
if(hang == 1) a = 0x80;
if(hang == 2) a = 0xc0;
{
P0 来自百度文库 command;
RS = 0;
RW = 0;
E = 1;
delay();
E = 0;
}
voidWrite_Data(ucharData)
{
P0 = Data;
RS = 1;
RW = 0;
E = 1;
delay();
E = 0;
}
voidLCD_Init(void)//初始化
{
Write_Command(0x01);
while(1)
{
LCD_Display(tab1);
time_view();
}
}
TR0 = 1;
}
void Time0_Int() interrupt 1
{
ucharcount;
TH0 = 0x4c;
TL0 = 0x00;
count++;
if(count == 20)
{
count = 0;
second++;
}
}
void main(void)
{
LCD_Init();
Time0_Init();
for(i=0;i<16;i++)
{
Write_Data(tab2[i]);
delay();
}*/
}
voidtime_view(void)
{
if(second == 60)
{
minite++;
second = 0;
}
if(minite== 60)
{
hour++;
minite= 0;
}
if(hour == 24)
{
hour = 0;
}
LCD_Printfc(2,4,hour/10+'0');
LCD_Printfc(2,5,hour%10+'0');
LCD_Printfc(2,6,':');
LCD_Printfc(2,7,minite/10+'0');
LCD_Printfc(2,8,minite%10+'0');
a = a + lie;
Write_Command(a);
Write_Data(sign);
}
voidLCD_Display(uchar*tab1)
{
uchari;
Write_Command(0x80);
for(i=0;i<16;i++)
{
Write_Data(tab1[i]);
delay();
}
/*Write_Command(0xc0);
#include<reg52.h>
#defineucharunsigned char
#defineuintunsignedint
unsigned char code tab1[16]=" Now time is: ";
unsigned char tab2[16]=" 00:00:00 ";
ucharsecond = 30;