background image

uchar cw[]={0x09,0x01,0x03,0x02,0x06,0x04,0x0c,0x08}; //正传
uchar code ducode[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};//定义段码
uchar code wecode[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};//定位段码

uchar tempdata[8],speed=10;

void delay(uchar z) //延时 1ms
{

uchar i,j;
for(i=z;i>0;i--)
for(j=110;j>0;j--);

}

void delay500us(void) //延时 500us
{
  int i;
  for(i=0;i<58;i++);
}

void buzzer()  //产生报警音
{

uchar t;

    for(t=0;t<100;t++)
    {

 

 delay500us();

 

 alarm=!alarm;   //产生脉冲

    }
    alarm=1;    //关闭蜂鸣器
}

void ccw_motor()//反转子程序
{

uchar i;
for(i=0;i<8;i++)//

   

旋转一周 内部旋转一周

{

for(i=0;i<8;i++)
{

st_mo=ccw[i];
delay(speed);

}

}

}