欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
單片機外部中斷按鍵次數(shù)統(tǒng)計顯示程序+Proteus仿真
[打印本頁]
作者:
1001du
時間:
2019-6-10 10:22
標題:
單片機外部中斷按鍵次數(shù)統(tǒng)計顯示程序+Proteus仿真
單片機外部中斷按鍵次數(shù)統(tǒng)計仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)
0.png
(21.15 KB, 下載次數(shù): 45)
下載附件
2019-6-10 17:49 上傳
單片機源程序如下:
#include <reg51.h>
#include <intrins.h>
// 1 外部中斷0初始化 2 中斷函數(shù)統(tǒng)計按鍵次數(shù)
// 3 顯示按鍵次數(shù)
#define SEG1 P1
#define SEG2 P2
#define SEG0 P0
//共陽極數(shù)碼管 //0 1 2 3 4 5 6 7 8 9 A b C d e F
unsigned char code DIG_CODE_CA[16]={0xC0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e};//共陽極數(shù)碼管
//共陰極數(shù)碼管 //0 1 2 3 4 5 6 7 8 9 A b C d e F
unsigned char code DIG_CODE_CC[16]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};//共陰極數(shù)碼管
sbit Key3=P3^2;
sbit Key4=P3^3;
unsigned int Num0=0;
unsigned int Num1=0;
//子函數(shù)
void Delay1ms();
void DelayNms(unsigned int n);
//主函數(shù)
void main()
{
//1 外部中斷0 1初始化
IT0=1;IT1=1;//TCON = 0x05;
EA=1;EX0=1;EX1=1;//IE=0x85;
while(1)
{
// 3 顯示按鍵次數(shù)
if(Num0==100)Num0=0;
SEG1=DIG_CODE_CC[Num0/10];
SEG2=DIG_CODE_CC[Num0%10];
if(Num1==10)Num1=0;
SEG0=DIG_CODE_CC[Num1];
}
}
//2 外部中斷0中斷函數(shù) 統(tǒng)計按鍵key3次數(shù)
void INT0_ISR() interrupt 0
{
DelayNms(10);
if(Key3==0)
Num0++;
}
//2 外部中斷1中斷函數(shù) 統(tǒng)計按鍵key4次數(shù)
void INT1_ISR() interrupt 2
{
DelayNms(10);
if(Key4==0)
Num1++;
}
//子函數(shù)聲明
void Delay1ms() //@12.000MHz
{
unsigned char i, j;
i = 2;
j = 239;
do
{
while (--j);
} while (--i);
}
void DelayNms(unsigned int n)
{
while(n--)
Delay1ms();
}
復制代碼
0.png
(10.25 KB, 下載次數(shù): 44)
下載附件
2019-6-10 17:49 上傳
所有資料51hei提供下載:
外部中斷按鍵次數(shù)統(tǒng)計.rar
(55.72 KB, 下載次數(shù): 18)
2019-6-10 10:20 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
歡迎光臨 (http://www.raoushi.com/bbs/)
Powered by Discuz! X3.1