本人初学者
大佬们帮我看看我做的代码是否有问题- #include<reg51.h>
- #include<intrins.h>
- #define uchar unsigned char
- #define uint unsigned int
- uchar code seg[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e,0x8c};
- sbit alarm=P3^0;
- sbit res=P3^7;
- void main()
- {
- uchar temp,key,a;
- key=16;
- alarm=1;
- P1=seg[key];
- P2=seg[key];
- while(1){
- lop:
- if(res==0) alarm=1;
- if(alarm==1){
- temp=P0;
- }
- else goto lop;
- switch(temp){
- case 0xfe:
- key=1;
- a=1;
- alarm=0;
- break;
- case 0xfd:
- key=2;
- a=2;
- alarm=0;
- break;
- case 0xfb:
- key=3;
- a=3;
- alarm=0;
- break;
- case 0xf7:
- key=4;
- a=4;
- alarm=0;
- break;
- case 0xef:
- key=5;
- a=5;
- alarm=0;
- break;
- case 0xdf:
- key=6;
- a=6;
- alarm=0;
- break;
- case 0xbf:
- key=7;
- a=7;
- alarm=0;
- break;
- case 0x7f:
- key=8;
- a=8;
- alarm=0;
- break;
- default:
- key=16;
- alarm=1;
- }
- P1=seg[key];
- if(res==0){
-
- P2=seg[a];
-
- }
- }
- }
复制代码 |