# include <reg52.h>
#define uint unsigned int
#define uchar unsigned char
uchar code step_table[]={
0xdc,0xcc,0xec,0xe4,0xf4,0xf0,0xf8,0xd8};
sbit A1=P0^5; //定义步进电机连接端口
sbit B1=P0^4;
sbit C1=P0^3;
sbit D1=P0^2;
void delay(uint t)
{
while(t--);
}
void main()
{
uint i;
while(1)
{
for(i=0;i<8;i++)
{
P0=step_table[i];
delay(200);
}
}
}
|