预览加载中,请您耐心等待几秒...
1/10
2/10
3/10
4/10
5/10
6/10
7/10
8/10
9/10
10/10

亲,该文档总共15页,到这已经超出免费预览范围,如果喜欢就直接下载吧~

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

仅供学习参考/****************************************************************************************************************************************************基于51单片机的数码管时钟程序******************************************************************************************************************************************************/#include<stdio.h>#defineuintunsignedint#defineucharunsignedcharsbitdula=P2^6;//申明u1锁存器的锁存端sbitwela=P2^7;//申明u2锁存器的锁存端sbitkey1=P3^0;//功能键sbitkey2=P3^1;//增大键sbitkey3=P3^2;//减小键sbitkey4=P3^3;//秒表查看键sbitbeep=P2^3;//蜂鸣端ucharnum,num1,num2,numm;ucharnumf,num,nums,num;uchars,s1,f,f1,m,m1;ucharns,ns1,nf,nf1;ucharnumns,numnf;uchardingshi;voiddisplay(ucharm,ucharm1,ucharf,ucharf1,uchars,uchars1);voiddisplay1(ucharnf,ucharnf1,ucharns,ucharns1);voidkey();voidkey1();voidalram();voiddi();voiddelayms(xms);voidT0_time()interrupt1;voidmiaobiao();ucharcodetable[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x77,0x7c,0x39,0x5e,0x79,0x71};/*********************************************************主函数voidmain()*********************************************************/intmain(){TMOD=0X01;TH0=(65536-46080)/256;TL0=(65536-46080)%256;EA=1;ET0=1;TR0=1;nums=12;numf=0;num2=0;num=0;while(1){if(dingshi==0){keyscan();display(m,m1,f,f1,s,s1);alarm();}else{miaobiao();keyscan1();display1(nf,nf1,ns,ns1);}}return0;}/*********************************************************蜂鸣器函数di()*********************************************************/voiddi(){beep=0;delayms(100);beep=1;}/**********************************************************按键调时函数key()**********************************************************/voidkeyscan(){if(key1==0){delayms(10);if(key1==0){nums++;if(nums==24);nums=0;while(!key1);di();display(m,m1,f,f1,s,s1);}}if(key2==0){delayms(10);if(key2==0){numf++;if(numf==24);numf=0;while(!key2);di();display(m,m1,f,f1,s,s1);}}if(key3==0){delayms(10);if(key3==0){dingshi=~dingshi;while(!key1);di();display(m,m1,f,f1,s,s1);}}}/**********************************************按键设定闹钟函数keyscan1();****************