下面是一个步进电机的演示程序:
#include sbit key=P2^0; //按键控制步进电机的方向 unsigned char speed=5; //步进电机的转速 //八拍方式驱动,顺序为A AB B BC C CD D DA unsigned char code clockWise[]={0x01,0x03,0x02,0x06,0x04,0x0c,0x08,0x0d}; void delay(unsigned char z) { unsigned char x,y; for(x=0;x