本帖最后由 7222 于 2020-4-20 07:05 編輯
代碼如下:
#include<reg51.h>
sbit P0_4=P0^4;
int count=0;
char led_mod[]={0x3f,0x06,0x5b,0x4f,0x66,0x7d,0x07,0x6f,0x77,0x58,0x5e,0x79,0x71};
int0_key() interrupt 0
{
P0_4=!P0_4;
}
int1_key() interrupt 2
{
count++;
if(count>0x0f)
count=0;
P2=led_mod[count];
}
void main(){
IT0=1;
EX0=1;
EA=1;
IT1=1;
EX1=1;
P0_4=0;
P2=0x3f;
while(1);
}
仿真圖如下:
J4V%GGQTP~]DCE0O07INM(I.png (29.97 KB, 下載次數: 45)
下載附件
2020-4-20 07:04 上傳
|