#include
/************************************************/
sbit Key=P2^0;
static unsigned char p=0;
void delay1ms(unsigned int count)
{
int x,y;
for(x=0;x for(y=0;y<120;y++);
}
/************************************************/
void ScanKey()
{
if(Key==0)
{
delay1ms(1);
if(Key==0)
{
p++;
if(p==8) p=0;
}
while(Key==0); //按键确定,每次按键只加1
}
}
/************************************************/
void main()
{
unsigned char i;
unsigned char a,b;
unsigned char temp=0x0f;
while(1)
{ ScanKey();
for(i=0;i<8;i++)
{
a=temp< b=temp>>(8-p);
P0=a|b;
}
}
}
{
int x,y;
for(x=0;x
}
/************************************************/
void ScanKey()
{
if(Key==0)
{
delay1ms(1);
if(Key==0)
{
p++;
if(p==8) p=0;
}
while(Key==0); //按键确定,每次按键只加1
}
}
/************************************************/
void main()
{
unsigned char i;
unsigned char a,b;
unsigned char temp=0x0f;
while(1)
{ ScanKey();
for(i=0;i<8;i++)
{
a=temp< b=temp>>(8-p);
P0=a|b;
}
}
}