刚看了帖子写的,参考下,没有长按,长按我还没想出来
#include<reg51.h>
#include<intrins>
#define uint unsigned int
uint temp,number;
sbit key1=P1^1
sbit key2=P1^2
void delay(uint k);
void main()
{
P0=0xf0;
P1=0xff;
while(1)
{
if(key1==0)
{
delay(5);
if(key1==0)
{
temp=P0;
temp=_crol_(temp,1);
while(!key1);
}
else
{
temp=P0;
temp=_crol_(temp,1);
}
if(key2==0)
{
delay(5);
if(key2==0)
{
temp=P0;
temp=_cror_(temp,1);
while(!key2);
}
else
{
temp=P0;
temp=_cror_(temp,1);
}
}
}
} |