單片機驅動步進電機例程
#define uint unsigned int
#define uchar unsigned char
void delay(uint z)
{
uchar i;
while(z--)
for(i=120;i>0;i--);
}
void main()
{
while(1)
{
P2=0X08;
delay(100);
P2=0X04;
delay(100);
P2=0X02;
delay(100);
P2=0X01;
delay(100);
}
}
評論