没有电路图,只有自由发挥了。这里P0口接LED,P1接按键
#include
#include
#define uchar unsigned char
sbit key_up=P1^0;
sbit key_dn=P1^1;
uchar cnt,keyval;
void t0isr()
void t0isr() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
cnt++;
if(cnt>=10)
{
cnt=0;
if(keyval==1)P0=_crol_(P0,1);
if(keyval==2)P0=_cror_(P0,1);
}
}
main()
{
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
TR0=1;
ET0=1;
EA=1;
while(1)
{
if(key_up==0)
{
while(key_up==0);
P0=0xfe;
keyval=1;
}
if(key_dn==0)
{
while(key_dn==0);
P0=0x7f;
keyval=2;
} }
}