|
前陣子寫的練習(xí),程序仿真都在里面
仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)
0.png (15.23 KB, 下載次數(shù): 61)
下載附件
2018-3-16 16:02 上傳
0.png (49.8 KB, 下載次數(shù): 61)
下載附件
2018-3-16 16:03 上傳
單片機源程序如下:
- #include<reg51.h>
- #include"key.h"
- #define uchar unsigned char
- #define uint unsigned int
- uchar number[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
- void main()
- {
- uchar cloose,l;
- uint o;
- while(1)
- {
- P0=0X00;
- SPEAKER=1;
- if(startkey()==1) //檢測是否按下開始按鈕
- {
- cloose=cloosekey(); //檢測是否有違規(guī)情況
- if(cloose==0) continue; //無人違規(guī) 則返回
- else P0=number[cloose]; //有人違規(guī),顯示號碼
- while(endkey()==1); //蜂鳴器長鳴
- for(o=0;o<500;o++)
- speaker();
- // while(endkey()==0);
-
- }
- else{P0=0x49;} //顯示“三”提示開始搶答
- while(endkey()==1)
- {
- cloose=cloosekey(); //檢測是否有選手搶答
- if(cloose!=0)
- {
- P0=number[cloose]; //顯示搶答選手號碼
- for(l=0;l<150;l++)
- speaker(); //有選手搶答則蜂鳴器響
- while(endkey()==1);
- break; //按下結(jié)束,本輪結(jié)束
- }
- }
-
- }
- }
復(fù)制代碼
所有資料51hei提供下載:
八路搶答器.rar
(54.64 KB, 下載次數(shù): 36)
2018-3-16 10:43 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
|
|