|
请问一下是什么问题我找半天找不出来
- #include<reg51.h>
- #define uchar unsigned char
- #define uint unsigned int
- #define LED P3
- #define undefined identifier
- uchar i, flagl,flag2,flag3,flag4;
- sbit k1=P2^4;
- sbit k2=P2^5;
- sbit k3=P2^6;
- sbit k4=P2^7;
- uchar table1[]={0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfc,0xff};
- uchar table2[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf};
- uchar table3[]={0x7e,0xbd,0xdb,0xe7,0xf};
- uchar table4[]={0xaa,0x55};
- void delay(uint x)
- {
- uint i;
- while(x--)
- for(i=50;i>0;i--);
- }
- void keyscan()
- {if(k1==0){
- delay(10);
- if(k1==0){
- flag2=0;
- flag3=0;
- flag4=0;
- flagl=1;
- }
- }
- if(k2==0){
- delay(10);
- if(k2==0){
- flag3=0;
- flagl=0;
- flag4=0;
- flag2=1;
- }
- }
- if(k3==0){
- delay(10);
- if(k3==0){
- flag1=0;
- flag2=0;
- flag4=0;
- flag3=1;
- }
- }
- if(k4==0){
- delay(10);
- if(k4==0){
- flag1=1;
- flag2=0;
- flag3=0;
- flag4=1;
- }
- }
- }
- void main(){
- while(1)
- {keyscan();
- if(flagl==1){
- for(i=0;i<16;i++){
- LED=table1[i];
- delay(200);
- keyscan();
- }
- }
- if(flag2==1){
- for(i=0;i<14;i++){
- LED=table2[i];
- delay(300);
- keyscan();
- }
- }
- if(flag3=-1){
- for(i=0;i<5;i++){
- LED=table3[i];
- delay(250);
- keyscan();
- }
- }
- if(flag4==1){
- for(i=0;i<2;i++){
- LED=table4[i];
- delay(600);
- keyscan();
- }
- }
- }
- }
复制代码 |
|