|
0.png (24.52 KB, 下載次數(shù): 109)
下載附件
2016-9-25 13:45 上傳
仿真工程文件及程序下載(為了防止有人白嫖Proteus,設(shè)置為只讀方式了,介意的話就不要下載了哦):
1602LCD PROTUS仿真.zip
(39.42 KB, 下載次數(shù): 57)
2016-9-25 13:46 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
源程序:
- #include<reg52.h>//籃球計(jì)時(shí)計(jì)分器
- #define uint unsigned int
- #define uchar unsigned char
- sbit k1=P1^0;
- sbit k2=P1^1;
- sbit k3=P1^2;
- sbit k4=P1^3;
- uchar code table[]={
- 0x3f,0x30,0x5b,0x4f,
- 0x66,0x6d,0x7d,0x07,
- 0x7f,0x6f};uchar shu1,shu2,shu3,num0;
- uchar a,b,c,d,e,f;
- void init()
- {
- TMOD=0x01;
- TH0=(65536-45872)/256;
- TL0=(65536-45872)%256;
- EA=1;
- ET0=1;
- TR0=1;
- num0=0;
- shu1=59;
- shu2=59;
- shu3=0;
- }
- void delay(uint xms)
- {
- uint i,j;
- for(i=xms;i>0;i--)
- for(j=110;j>0;j--);
- }
- void display()
- {
- a=shu1/10;
- b=shu1%10;
- c=shu2/10;
- d=shu2%10;
- //e=shu3/10;
- //f=shu3%10;
- P2=0xfe;
- P0=table[a];
- delay(5);
- P2=0xfd;
- P0=table[b];
- delay(5);
- P2=0xfb;
- P0=table[c];
- delay(5);
- P2=0xf7;
- P0=table[d];
- delay(5);
- //P2=0xef;
- //P0=table[e];
- //delay(5);
- //P2=0xdf;
- //P0=table[f];
- //delay(5);
- }
- void kscan()
- {
- if(k1==0)
- {
- delay(2);
- if(k1==0)
- {
- while(!k1);
- TR0=~TR0;
- }
- }
- if(k2==0)
- {
- delay(2);
- if(k2==0)
- {
- while(!k2);
- TR0=0;
- shu1=0;
- shu2=0;
- }
- }
- if(k3==0)
- {
- delay(2);
- if(k3==0)
- {
- while(!k3);
- shu3++;
- if(shu3==100)
- shu3=0;
- }
- }
- if(k4==0)
- {
- delay(2);
- if(k4==0)
- {
- while(!k4);
- shu3--;
- if(shu3==0)
- shu3=0;
- }
- }
- }
- void main()
- {
- init();
- while(1)
- {
- kscan();
- display();
- if(num0==20)
- {
- num0=0;
- shu2--;
- if(shu2==-1)
- {
- shu2=59;
- shu1--;
- if(shu1==-1)
- {
- shu1=59;
- }
- }
- }
- }
- }
- void T0_time() interrupt 1
- {
- TH0=(65536-45872)/256;
- TL0=(65536-45872)%256;
- num0++;
-
- }
復(fù)制代碼
|
|