[img]https://bbs.21ic.com/ [/img]  
 
我用逐行扫描法为什么不行呢?这里只列出第一行,请指出其中的问题 
#include<reg52.h> 
#define unint unsigned int 
#define unchar unsigned char 
unchar code led[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82, //0,1,2,3,4,5,6 
  0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e,0xBF,0xff}; 
unchar temp,num; 
void delay(unint z); 
void main() 
{  
  P2=0xff; 
  P0=0xff; 
  while(1) 
  {   
       P1=0xef; 
    temp=P1; 
    temp=temp&0x0f; 
    if (temp!=0x0f) 
        {     
       delay(5); 
     temp=P1; 
     temp=temp&0x0f; 
        if (temp!=0x0f) 
             { 
        temp=P1; 
        switch (temp) 
        { 
       case 0xee: num=0; break; 
       case 0xed: num=1; break; 
       case 0xeb: num=2; break; 
       case 0xe7: num=3; break; 
  
     }  
          while(temp!=0x0f);  
      delay(5); 
      while(temp!=0x0f);  
      
      
               } 
      P2=0x00; 
         P0=led[num];  
            } 
   
 } 
} 
void delay(unint z) 
{ 
  unint x,y; 
   for(x=z;x>0;x--) 
    for(y=110;y>0;y--); 
} |