完善资料让更多小伙伴认识你,还能领取20积分哦,立即完善>
扫一扫,分享给好友
#include #define uchar unsigned char #define uint unsigned int ***it LCD_RS=P2^6; ***it LCD_RW=P2^5; ***it LCD_E=P2^7; ***it k2=P3^0; long int count,count1; char mil,sec,min,mil1,sec1,min1; unsigned char code table[ ]=" miaobiao "; unsigned char code table1[ ]=" 00:00:0 "; void delay(uint z) { uchar j,k; for(j=z;j>0;j--) for(k=256;k>0;k--); } void write_com(uchar com) { LCD_RS=0; LCD_E=0; LCD_RW=0; LCD_DATAPINS=com; delay(5); LCD_E=1; delay(5); LCD_E=0; } void write_date(uchar date) { LCD_RS=1; LCD_E=0; LCD_RW=0; LCD_DATAPINS=date; delay(5); LCD_E=1; delay(5); LCD_E=0; } void init() { uchar num; LCD_E=0; write_com(0x38); write_com(0x0c); write_com(0x06); write_com(0x01); write_com(0x80); for(num=0;num<20;num++) { write_date(table[num]); delay(5); } write_com(0x80+0x40); for(num=0;num<12;num++) { write_date(table1[num]); delay(5); } TMOD=0x01; TH0=(65536-50000)/256; TL0=(65536-50000)%256; EA=1; ET0=1; EX0=1; TR0=0; } void write_min(uchar add,uchar date) { uchar one,two; one=date/10; two=date%10; write_com(0x80+0x40+add); write_date(0x30+one); write_date(0x30+two); } void write_sec(uchar add,uchar date) { uchar three,four; three=date/10; four=date%10; write_com(0x80+0x40+add); write_date(0x30+three); write_date(0x30+four); } void write_mil(uchar add,uchar date) { uchar five; five=date%10; write_com(0x80+0x40+add); write_date(0x30+five); } void zjs() { if(count==2) { delay(5); count=0; mil++; if(mil==10) { delay(5); mil=0; sec++; if(sec==60) { delay(5); sec=0; min++; if(min==60) { delay(5); min=0; mil=0; } } } write_min(4,min); write_sec(7,sec); write_mil(10,mil); } } void main() { init(); while(1) { zjs(); } } void int0() interrupt 0 { delay(10); TR0=~TR0; } void timer0() interrupt 1 { count++; }
发布
【有奖征文】赢千元现金!发文章、上传资料送壕礼
21080 浏览1 评论
【RISC-V开放架构设计之道|阅读体验】+ 个人心得并祝福
2014 浏览1 评论
【创作者激励】技术探索官—优秀原创作者扶持计划
9882 浏览6 评论
【双重好礼】赢千元创作金!创作之星原创征文来啦~
6887 浏览19 评论
【大赛报名】V853芯片免费体验!华秋电子X全志在线开源硬件设计大赛
24188 浏览3 评论
德赢Vwin官网 网
德赢Vwin官网 论坛
查看 »
小黑屋|手机版|Archiver|德赢Vwin官网(湘ICP备2023018690号)
GMT+8, 2024-8-23 15:35, Processed in 0.771897 second(s), Total 63, Slave 48 queries .
Powered by德赢Vwin官网 网
© 2015bbs.elecfans.com