用12864显示时间的程序.docx

上传人:b****6 文档编号:9010169 上传时间:2023-02-02 格式:DOCX 页数:9 大小:14.58KB
下载 相关 举报
用12864显示时间的程序.docx_第1页
第1页 / 共9页
用12864显示时间的程序.docx_第2页
第2页 / 共9页
用12864显示时间的程序.docx_第3页
第3页 / 共9页
用12864显示时间的程序.docx_第4页
第4页 / 共9页
用12864显示时间的程序.docx_第5页
第5页 / 共9页
点击查看更多>>
下载资源
资源描述

用12864显示时间的程序.docx

《用12864显示时间的程序.docx》由会员分享,可在线阅读,更多相关《用12864显示时间的程序.docx(9页珍藏版)》请在冰豆网上搜索。

用12864显示时间的程序.docx

用12864显示时间的程序

#include

#defineucharunsignedchar

#defineuintunsignedint

ucharmiao,shi,fen;

ucharcount=0,num;

uchartable[]="2013-10-28周一";

sbitrs=P2^7;

sbitrw=P2^6;

sbite=P2^5;

sbitpsb=P2^2;

sbits1=P3^0;

sbits2=P3^1;

sbits3=P3^2;

voiddelay_ms(uintx)

{

uintj;

while(x--)

for(j=0;j<115;j++);

}

///写数据

voidcom(ucharcom)

{

rs=0;

rw=0;

P0=com;

delay_ms(5);

e=1;

delay_ms(5);

e=0;

}

///读数据

voiddat(uchardat)

{

rs=1;

rw=0;

P0=dat;

delay_ms(5);

e=1;

delay_ms(5);

e=0;

}

////////////

voidwrite_sfm(ucharadd,ucharnum)

{

ucharshi,ge;

shi=num/10;

ge=num%10;

com(0x80+add);

dat(0x30+shi);

dat(0x30+ge);

}

///初始化

voidinit()

{

//uchari;

fen=0;

shi=12;

miao=0;

count=0;

num=0;

psb=1;

com(0x30);

delay_ms(5);

com(0x0f);

delay_ms(5);

com(0x01);//清0

delay_ms(5);

com(0x06);

delay_ms(5);

com(0x0c);

delay_ms(5);

com(0x80);

delay_ms(5);

com(0x91);

dat(':

');

delay_ms

(2);

com(0x93);

dat(':

');

delay_ms

(2);

/*com(0x94);*/

write_sfm(0x14,miao);

delay_ms

(2);

write_sfm(0x12,fen);

delay_ms

(2);

write_sfm(0x10,shi);

////定时器

TMOD=0X01;

TH0=(65536-46083)/256;

TL0=(65536-46083)%256;

EA=1;

ET0=1;

TR0=1;

}

///显示函数

voiddisp1()////第一行

{

uchari;

com(0x80);

for(i=0;i<14;i++)

{

dat(table[i]);

delay_ms(4);

}

}

voidt0()interrupt1

{

TH0=(65536-46083)/256;

TL0=(65536-46083)%256;

count++;

if(count==20)

{

count=0;

miao++;

if(miao==60)

{

miao=0;

fen++;

if(fen==60)

{

fen=0;

shi++;

if(shi==24)

{

shi=0;

}

write_sfm(0x10,shi);

}

write_sfm(0x12,fen);

}

write_sfm(0x14,miao);

}

}

/////

voidkey()

{

if(s1==0)

{

delay_ms(5);

if(s1==0)

{

num++;

while(!

s1);

if(num==1)

{

TR0=0;

com(0x94);

com(0x0f);

}

if(num==2)

com(0x92);

if(num==3)

com(0x90);

if(num==4)

{

num=0;

com(0x0c);

TR0=1;

}

}

}

if(num!

=0)

{

if(s2==0)

{

delay_ms(5);

if(s2==0)

{

while(!

s2);

if(num==1)

{

miao++;

if(miao==60)

miao=0;

write_sfm(0x14,miao);

com(0x94);

}

if(num==2)

{

fen++;

if(fen==60)

fen=0;

write_sfm(0x12,fen);

com(0x92);

}

if(num==3)

{

shi++;

if(shi==24)

shi=0;

write_sfm(0x10,shi);

com(0x90);

}

}

}

if(s3==0)

{

delay_ms(5);

if(s3==0)

{

while(!

s3);

if(num==1)

{

miao--;

if(miao==-1)

miao=59;

write_sfm(0x14,miao);

com(0x94);

}

if(num==2)

{

fen--;

if(fen==-1)

fen=59;

write_sfm(0x12,fen);

com(0x92);

}

if(num==3)

{

shi--;

if(shi==-1)

shi=23;

write_sfm(0x10,shi);

com(0x90);

}

}

}

}

}

///主函数

voidmain()

{

init();

disp1();

while

(1)

key();

}

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高等教育 > 农学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1