怎样改这个程序能使舵机转动一个60度的角?
#include<reg52.h>
#include<intrins.h>
#define uint unsigned int
#define uchar unsigned char
#define nop() _nop_()
uchar code tablez[]={0x03,0x06,0x0c,0x09};
uchar code tablef[]={0x03,0x09,0x0c,0x06};
#define motor P1
void delay(uchar ms)
{
uchar j;
while(ms--)
{
for(j=0;j<250;j++);
}
}
void main()
{
uchar i,j;
while(1)
{
j=0;
for(i=0;i<255;i++)//三圈
{
motor=0x00;
motor=tablez[j];
j++;
if(j>=4) j=0;
delay(2);
}
delay(200);
delay(200);
delay(200);
j=0;
for(i=0;i<255;i++)
{
motor=0x00;
motor=tablef[j];
j++;
if(j>=4) j=0;
delay(2);
}
delay(200);
delay(200);
delay(200);
}
}
|