这是源程序,求大神指点,我知道我写的不对。。。 
[mw_shl_code=c,true]#include <reg51.h>	   
#include <intrins.h>
#define  GPIO_LED P0  //led使用P0口
sbit K1=P1^0;
sbit K2=P1^1;
//--定义全局函数--//
unsigned char code DIG_CODE[17]={
0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
//0、1、2、3、4、5、6、7、8、9、A、b、C、d、E、F的显示码
void Delay10ms(unsigned int c);   //延时10ms
unsigned char Key_Scan();
char KeyValue;
void main(void)
{ 
   while(1)
   {
     Key_Scan();
     GPIO_LED=~DIG_CODE[KeyValue];
   }				
}
unsigned char Key_Scan()
{
	unsigned char i; //保存键值
    i=0;
	if (K1==0||K2==0)		//检测按键是否按下
	{
		Delay10ms(1);	//消除抖动
		if (K1==0||K2==0)	//再次检测按键是否按下
		{	KeyValue=0;
            if(K1==0) 
			{
			KeyValue++;
			if(KeyValue>17)
			KeyValue=0;
			}
			if(K2==0)
			{ 
			KeyValue--;
			if(KeyValue<0)
			KeyValue=17;
			}
			while ((i<50) && K1!=0 && K2!=0)	 //检测按键是否松开
			{
				Delay10ms(1);
				i++;
			}
		}
	}
}
void Delay10ms(unsigned int c)   //误差 0us
{
    unsigned char a, b;
    for (;c>0;c--)
	{
		for (b=38;b>0;b--)
		{
			for (a=130;a>0;a--);
		}
           
	}       
}[/mw_shl_code]
 
  |