//2相4线时序码表,从左而右正转,从右而左反转
unsigned char code motor_2p4l[]={0x01,0x05,0x04,0x06,0x02,0x0a,0x08,0x09};//低4位
sbit a1 = P3^2; //A+
sbit a2 = P3^3; //A-
sbit b1 = P5^5; //B+
sbit b2 = P5^4; //B-;
//8拍动作:
for (i=0;i<8;i++)
{
if (dir) mdata=motor_2p4l[i];
else mdata=motor_2p4l[7-i];
a1=mdata & 0x01;
a2=mdata & 0x02;
b1=mdata & 0x04;
b2=mdata & 0x08;
delay_step(delay);
} |