} //K1 end
if(K2==0)
{
beep();
if(snum_dr==1)
{ snum++;
snum1=snum;
if(snum==0x14)
{ snum_dr=~snum_dr;}
}
else
{snum--;
snum1=snum;
if(snum==0x01)
{ snum_dr=~snum_dr; }
}
} //K2 end
if(K3==0)
{
beep();
direction=~direction;
motor_DR();
}//K3 end
if(K4==0)
{
beep();
if(rate_dr==1)
{ rate++;
if(rate==0x10)
{ rate_dr=~rate_dr;}
}
else
{
rate--;
if(rate==0x01)
{ rate_dr=~rate_dr; }
}
} //K4 end
if(number1==snum1) //与设定圈数是否相等
{ number1=0;
on_off=0;
TR0=0;
snum=snum1;
P1 =0xf0;
motor_RUN();
}
data_dis();
} // while(1) end
} //main end
void motor_onoff() interrupt 1
{
TL0 = 0x33;
TH0 = 0xf5;
q++;
if(q < rate)
{ return; }
else
{ q=0;
number++; //脉冲计数
if(number==96) //96个脉冲电机转一圈
{ snum--;
number=0;
number1++; } //电机转动圈数
if(direction==1) //方向标志
{ if(v<8)
{P1 = FFW[v];v++;} //取数据,正转
if(v==8)
{ v=0; }
}
else
{ if(v<8)
{P1 = REV[v];v++;} //取数据,反转
if(v==8)
{ v=0; }
}
}
}