程序如下,但是步进电机没有反应,是何原因?
#include<reg52.h>
sbit A1=P1^0;
sbit A2=P1^1;
sbit B1=P1^2;
sbit B2=P1^3;
sbit ENA=P1^4; //使能A
sbit ENB=P1^5; //使能B
unsigned char code Table[4]={0x35,0x36,0x3a,0x39};
sta
tic int cstep=0;
void InitMotor()
{
P1=Table[0];
}
void main()
{
EA=1;
ET0=1;
TMOD=0xd8;
TH0=0xf0;
TL0=0xb0;
TR0=1;
InitMotor();
P2=0;
while(1);
}
void Time0() interrupt 1
{
cstep++ ;
cstep=cstep%4;
P1=Table[cstep];
P2=~P2; //灯
}
一周热门 更多>