#include <reg52.h>
#define uint unsigned int
#define uchar unsigned char
sbit dula=P2^6;
uchar code bujinz[]={0xdc,0xcc,0xec,0xe4,0xf4,0xf0,0xf8,0xd8};
uchar code bujinf[]={0xd8,0xf8,0xf0,0xf4,0xe4,0xec,0xcc3,0xdc};
void delay (uint t)
{
while(t–);
}
void main()
{
uint i,angle=270,j,x;
P0=00; //关闭数码管显示
delay(500);
dula=1;
delay(500);
dula=0;
while(1)
{
for(i=0;i<=8;i++)
{
P0=bujinz[i];
delay(100);
}
for(i=0;i<=64/5.625angle;i++)//走1步1个脉冲式 5.625度 现在减速比是 64步 5.625度 走x度是 64/5.625x
{
P0=bujinz[x];
delay(100);
x++;
if(x==8)
x=0;
} //注意不能写成P0=bujinz[i]没有bujinz[i大于7]
while(1);
}
}