標題:
單片機按鍵中斷程序
[打印本頁]
作者:
1463307579
時間:
2020-5-7 10:16
標題:
單片機按鍵中斷程序
按鍵中斷
#include<reg51.h>
unsigned char code aaa[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
sbit K1=P3^7;
sbit LED1=P2^0;
void Delay(unsigned int a);
void Delay10ms();
unsigned char xx;
void main()
{
IT0=1;
EX0=1;
IT1=1;
EX1=1;
EA=1;
while(1)
{
if(xx==13)
{
xx=0;
}
if(xx==255)
{
xx=12;
}
P2=aaa[xx/10];
P1=0xFE;
Delay(5);
P2=0x00;
P2=aaa[xx%10];
P1=0xFD;
Delay(5);
P2=0x00;
}
}
void Int0() interrupt 0
{
Delay(1);
xx++;
}
void Int1() interrupt 2
{
Delay(1);
xx--;
}
void Delay(unsigned int c)
{
unsigned char a,b;
for(;c>0;c--)
for(b=38;b>0;b--)
for(a=130;a>0;a--);
}
復制代碼
按鍵中斷.zip
2020-5-7 10:15 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
53.17 KB, 下載次數(shù): 5, 下載積分: 黑幣 -5
按鍵中斷
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1