#include<reg52.h>
unsigned long beats = 0;
void StartMotor (unsigned long angle);
void main()//zd
{
EA=1;
TMOD=0x01;
TH0 =0xF8;
ET0 =1;
TR0 =1;
StartMotor(360*2);
while (1);
}
void StartMotor (unsigned long angle);
{
EA=0;
beats=(angle*4076)/360;
EA=1;
}
void ZD0() interrupt 1
{ unsigned char tmp;
static unsigned char index =0;
unsigned char code BeatCode [8]= {0xE,0xC,0xD,0x9, 0xB, 0x3, 0x7,};
TH0=0xF8;
TL0=0xCD;
if (beats!=0)
{
tmp = P1;
tmp=tmp&0xF0;
tmp=tmp | BeatCode [index];
index++;
index=index &0x07
beats--;
}
else
{
P1=P1 |0x0F;
}
}
|