大三,,求教大家。这个步进电机的程序没有反应
#include<reg52.h>
sbit LA=P2^0;
sbit LB=P2^1;
sbit LC=P2^2;
sbit LD=P2^3;
void right(unsigned int Speed,unsigned int Road);
void left(unsigned int Speed,unsigned int Road);
void mDelay(unsigned int DelayTime);
int MotorStep=0;
void main()
{
P2&=0xF0;
right(20,2);
mDelay(50);
left(20,2);
}
void right(unsigned int Speed,unsigned int Road)
{
while(Road)
{
switch(MotorStep)
{
case0:
LB=0;
LC=0;
LD=0;
LA=1,
MotorStep=1;
break;
case1:
LA=0;
LC=0;
LD=0;
LB=1;
MotorStep=2;
break;
case2:
LA=0;
LB=0;
LD=0;
LC=1;
MotorStep=3;
break;
case3:
LA=0;
LB=0;
LC=0;
LD=1;
MotorStep=0;
break;
}
mDelay(Speed);
Road--;
}
P2&0xF0;
}
void left(unsigned int Speed,unsigned int Road)
{
while(Road)
{
switch(MotorStep)
{
case3:
LB=0;
LC=0;
LD=0;
LA=1;
MotorStep=2;
break;
case2:
LA=0;
LC=0;
LD=0;
LB=1;
MotorStep=1;
break;
case1:
LA=0;
LB=0;
LD=0;
LC=1;
MotorStep=0;
break;
case0:
LA=0;
LB=0;
LC=0;
LD=1;
MotorStep=3;
break;
}
mDelay(Speed);
Road--;
}
P2&0xF0;
}
void mDelay(unsigned int DelayTime)
{
unsigned char j=0;
while(DelayTime--)
{
for (j=0;j<100;j++){}
}
}