#include
#define uchar unsigned char
uchar step[]={0x11,0x33,0x22,0x66,0x44,0xcc,0x88,0x99};
uchar spd=10,num=0;
sbit keyu=P3^0;
sbit keyd=P3^1;
void t0isr() interrupt 1
{
num++;
if(num>=spd)
{
num=0;
motor++;
motor%=8;
P0=step[motor];
P1=step[motor];
}
}
main()
{
TMOD=0x02;
TH0=6;
TL0=6;
ET0=1;
TR0=1;
EA=1;
while(1)
{
if(keyu==0)
{
while(keyu==0);
spd++;
if(spd>40)spd=40;
}
if(keyd==0)
{
while(keyd==0);
spd--;
if(spd<5)spd=5;
}
}
}