|
四、 實(shí)驗(yàn)總結(jié):
雖然這次的上級(jí)實(shí)驗(yàn)不難,但是還有點(diǎn)小問題,中間有一些的代碼出現(xiàn)了一些錯(cuò)誤,還是課本上的一些沒有記清楚,導(dǎo)致寫的時(shí)候出現(xiàn)了好幾個(gè)錯(cuò)誤,由此可知還是看書看的太少,以后得多看看書,然后多做一些實(shí)驗(yàn)練習(xí)練習(xí)。
0.jpg (39.15 KB, 下載次數(shù): 43)
下載附件
2018-4-12 03:56 上傳
二、程序設(shè)計(jì)流程圖
0.jpg (22.56 KB, 下載次數(shù): 42)
下載附件
2018-4-12 03:56 上傳
單片機(jī)源程序如下:
- #include<reg51.H>
- sbit P3_2=P3^2;
- sbit P3_3=P3^3;
- unsigned char code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};//共陰LED段碼表
- unsigned char count=0;
- void delay(unsigned int time){//延遲函數(shù)
- unsigned int j=0;
- for(;time>0;time--)
- for(j=0;j<125;j--);
- }
- void main(void){
- count=0;
- P1=table[count/10];
- P2=table[count%10];
- while(1){
- if(P3_2==0){
- delay(10);
- if(P3_2==0){
- count++;
- if(count==100)
- count=0;//滿一百歸零
- P1=table[count/10];
- P2=table[count%10];
- while(P3_2==0);
- }
- }
- if(P3_3==0){
- delay(10);
- if(P3_3==0){
- count--;
- if(count==-1)
- count=99;
- P1=table[count/10];
- P2=table[count%10];
- while(P3_3==0);
- }
- }
- }
- }
復(fù)制代碼
所有資料51hei提供下載:
LED數(shù)碼顯示.docx
(73.18 KB, 下載次數(shù): 9)
2018-4-11 20:33 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
|
|