要求如果按下兩個按鈕紅燈亮數碼管顯示FF要怎么搞啊
- #include <reg51.h>
- char led_mod[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
- char key_buf[]={0xee,0xde,0xbe,0xed,0xdd,0xbd,0xeb,0xdb,0xbb,0xe7,0xd7,0xb7};
- sbit P3_0=P3^0;
- sbit P3_1=P3^1;
- void getKey() interrupt 0
- {
- char key_scan[]={0xef,0xdf,0xbf,0x7f};
- char i=0,j=0,c=0;
- int a=0;
- for(i=0;i<4;i++)
- {
- P2=key_scan[i];
- for(j=0;j<12;j++)
- {
- if(key_buf[j]==P2)
- {
- P3_0=0;
- if(j<10)
- {
- P0=led_mod[0];
- P1=led_mod[j];
- }
- else if(j>=10)
- {
- P0=led_mod[j/10];
- P1=led_mod[j%10];
- }
- a++;
- break;
- }
- }
- if(a>1)
- {
- P3_0=1;
- P3_1=0;
- P0=0x71;
- P1=0x71;
- break;
- }
- }
- a=0;
- P2=0x0f;
- }
- void main(void)
- {
- IT0=1;
- EX0=1;
- EA=1;
- P2=0x0f;
- P0=0x00;
- P1=0x00;
- P3_0=1;
- P3_1=1;
- while(1)
- {
- if(P2==0x0f)P3_0=1;
- if(P2==0x0f)P3_1=1;
- }
- }
復制代碼
|