|
這是我做的基于單片機(jī)的數(shù)字時(shí)鐘課程設(shè)計(jì)用AD10畫的原理圖 PCB圖
實(shí)物,代碼都是原創(chuàng)
在附件中,請(qǐng)大家多多指教。
制作出來的實(shí)物圖:
1.003.jpg (76.46 KB, 下載次數(shù): 56)
下載附件
2017-11-24 02:41 上傳
1.002.jpg (144.53 KB, 下載次數(shù): 61)
下載附件
2017-11-24 02:41 上傳
1.001.jpg (98.11 KB, 下載次數(shù): 47)
下載附件
2017-11-24 02:41 上傳
單片機(jī)源程序如下:
- #include <reg52.h>
- sbit k0=P1^0;
- sbit k1=P1^1;
- sbit k2=P1^2;
- unsigned char second,minute,hour,i,k,l,j,x,y;
- unsigned int n;
- unsigned char code mod[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
- 0x7f,0x6f};
- timer0(void) interrupt 1
- {
- n++;
- TH0=0x3c;
- TL0=0xb0;
- }
- void delay()
- { unsigned int time,p;
- for(time=30;time>0;time--)
- for(p=0;p<10;p++);
- }
- void xianshi()
- {
- if(n==20)
- {
- n=0;
- second++;
- while(second==60)
- { second=0;
- minute++;
- if(minute==60)
- {minute=0;
- hour++;
- if(hour==24)
- {
- hour=0;
- }}}}
- x=hour%10;
- y=hour/10;
- l=minute%10;
- j=minute/10;
- i=second%10;
- k=second/10;P0=0x00;
- P2=0x01;
- P0=mod[i];
- delay();P0=0x00;
- P2=0x02;
- P0=mod[k];
- delay();P0=0x00;
- P2=0x04;
- P0=0x40;
- delay();P0=0x00;
- P2=0x08;
- P0=mod[l];
- delay();P0=0x00;
- P2=0x10;
- P0=mod[j];
- delay();P0=0x00;
- P2=0x20;
- P0=0x40;
- delay();P0=0x00;
- P2=0x40;
- P0=mod[x];
- delay();P0=0x00;
- P2=0x80;
- P0=mod[y];
- delay();P0=0x00;
- }
- void kongzhi()
- {if(k0==0)
- {TR0=0;
- while(k0==0) xianshi();
- delay();
- while(k0==1)
- {if(k1==0)
- {minute++;
- while(minute==60)
- {minute=0;
- }}
- while(k1==0) xianshi();
- if(k2==0)
- {minute--;
- while(minute==-1)
- {minute=59;
- }}
- while(k2==0) xianshi();
- xianshi();
- }
- if(k0==0)
- {TR0=0;
- while(k0==0) xianshi();
- delay();
- while(k0==1)
- {if(k1==0)
- {hour++;
- while(hour==24)
- {hour=0;
- }}
- while(k1==0) xianshi();
- if(k2==0)
- {hour--;
- while(hour==-1)
- {hour=23;
- }}
- while(k2==0) xianshi();
- xianshi();
- }
- if(k0==0)
- {while(k0==0) xianshi();
- TR0=1;
- ……………………
- …………限于本文篇幅 余下代碼請(qǐng)從51黑下載附件…………
復(fù)制代碼
所有資料51hei提供下載:
基于STC89C52的數(shù)字時(shí)鐘設(shè)計(jì).docx
(846.16 KB, 下載次數(shù): 25)
2017-11-23 23:18 上傳
點(diǎn)擊文件名下載附件
word文檔 下載積分: 黑幣 -5
|
|