51单片机,3相步进电机驱动代码

void main(void)
{
	unsigned char Mot_Ctrl = 0x04;
	unsigned char i = 0;
	//通过 P3.2,P3.3,P3.4 IO口驱动,低电平驱动
	while(1)
	{
		Delay500ms();
		P3 |= 0x1C;
		P3 = ~Mot_Ctrl & P3;
		Mot_Ctrl <<= 1;	
		Mot_Ctrl = Mot_Ctrl == 0x20 ? 0x04 : Mot_Ctrl;
	}
}