完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
#include #define uchar unsigned char #define uint unsigned int uchar table[]="tiME"; ***it lcden=P3^4; ***it lcdrs=P3^5; ***it beep=P3^6; extern void key1(); extern void key2(); extern void key3(); uchar num,hour=12,minite,second, ahour,aminite,asecond,a,F_k1,F_k2,F_k3; void delay(uint z) { uint x,y; for(x=z;x>0;x--) for(y=110;y>0;y--); } void write_com(uchar com) { lcdrs=0; P0=com; delay(5); lcden=1; delay(5); lcden=0; } void write_data(uchar date) { lcdrs=1; P0=date; delay(5); lcden=1; delay(5); lcden=0; } void write_add(uchar add,uchardate) { uchar aa,bb; aa=date/10; bb=date%10; write_com(0x80+add); write_data(0x30+aa); write_data(0x30+bb); } void init() { lcden=0; write_com(0x38); write_com(0x0c); write_com(0x06); write_com(0x01); write_com(0x80); } void display(uchar h,uchar m,uchars) { write_com(0x80+0x04); write_data(':'); write_data(0x30+(h/10)); write_data(0x30+(h%10)); write_data(':'); write_data(0x30+(m/10)); write_data(0x30+(m%10)); write_data(':'); write_data(0x30+(s/10)); write_data(0x30+(s%10)); write_data(' '); write_data(' '); write_data(' '); write_data(' '); } void main() { init(); TMOD=0X01; TH0=(65535-50000)/256; TL0=(65535-50000)%256; EA=1; TR0=1; ET0=1; for(num=0;num<4;num++) { write_data(table[num]); } while(1) { key1(); key2(); key3(); if(ahour==hour&&aminite==minite&&second<10) { beep=~beep; } if(F_k1==0&F_k3==0) display(hour,minite,second); } } void timer0() interrupt 1 { TH0=(65535-50000)/256; TL0=(65535-50000)%256; a++; if(a==20) { a=0; second++; if(second==60) { second=0; minite++; if(minite==60) { minite=0; hour++; if(hour==24) { hour=0; } } } } } #include "reg52.h" #define uchar unsigned char #define uint unsigned int ***it k1=P1^0; ***it k2=P1^1; ***it k3=P1^2; extern uchar F_k1,F_k3,second,minite,hour,ahour,aminite,asecond; extern void write_com(uchar com); extern void write_add(ucharadd,uchar date); extern void display(uchar h,ucharm,uchar s); void delay_key(int i) {while(i--);} void key1() { if(k1==0) { delay_key(100); if(k1==0) { TR0=0; while(!k1); F_k1++; if(F_k1==4) { F_k1=0; write_com(0x0c); TR0=1; } } } if(F_k1==1|F_k3==1) { write_com(0x80+0x0c); write_com(0x0f); } if(F_k1==2|F_k3==2) write_com(0x80+0x09); if(F_k1==3|F_k3==3) write_com(0x80+0x06); } void key2() { if(k2==0) { delay_key(100); { while(!k2); if(F_k1==1) { second++; if(second==60) second=0; write_add(0x0b,second); } if(F_k1==2) { minite++; if(minite==60) minite=0; write_add(0x08,minite); } if(F_k1==3) { hour++; if(hour==24) hour=0; write_add(0x05,hour); } if(F_k3==1) { asecond++; if(asecond==60) asecond=0; write_add(0x0b,asecond); } if(F_k3==2) { aminite++; if(aminite==60) aminite=0; write_add(0x08,aminite); } if(F_k3==3) { ahour++; if(ahour==24) ahour=0; write_add(0x05,ahour); } } } } void key3() { if(k3==0) { delay_key(100); if(k3==0) { while(!k3); F_k3++; if(F_k3==4) { F_k3=0; write_com(0x0c); } if(F_k3==1) display(ahour,aminite,asecond); } } } |
|
相关推荐
2个回答
|
|
程序看懂了直接删就是了
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
使用Keil建立完整的工程,并使用外部中断0触发数码管显示903
280 浏览 0 评论
嵌入式学习-飞凌嵌入式ElfBoard ELF 1板卡-使用AHT20进行环境监测之AHT20传感器介绍
1083 浏览 0 评论
846 浏览 0 评论
886 浏览 1 评论
基于瑞萨FPB-RA4E2智能床头灯项目——1编译环境搭建与点亮驱动ws2812全彩LED
869 浏览 0 评论
【youyeetoo X1 windows 开发板体验】少儿AI智能STEAM积木平台
11824 浏览 31 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-30 11:54 , Processed in 0.577530 second(s), Total 48, Slave 41 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号