舵机程序之数据的处理
#define BIAOZHI(x,y,z) Biaozhi=x;Biaozhip=y;Biaozhit=z
char ASC_zhuan_Valu(char asc)
{
char valu;
switch(asc)
{
case 0x30:valu=0;break; //0的ASC码时0x30,,十进制48
case 0x31:valu=1;break;
case 0x32:valu=2;break;
case 0x33:valu=3;break;
case 0x34:valu=4;break;
case 0x35:valu=5;break;
case 0x36:valu=6;break;
case 0x37:valu=7;break;
case 0x38:valu=8;break;
case 0x39:valu=9;break;
}
return valu;
}
void shujuchuli(char *Huancen,unsigned int *Pwm)//数据处理
{
char Biaozhi,Biaozhip,Biaozhit;
unsigned int Shuju=0,Shujup=0,Shujut=0;
while(*Huancen!=10)
{
if(Biaozhi==1&*Huancen!=80&*Huancen!=84)
{
Shuju=Shuju*10+ASC_zhuan_Valu(*Huancen);
}
if(Biaozhip==1&*Huancen!=35&*Huancen!=84)
{
Shujup=Shujup*10+ASC_zhuan_Valu(*Huancen);
}
if(Biaozhit==1&*Huancen!=80&*Huancen!=35)
{
Shujut=Shujut*10+ASC_zhuan_Valu(*Huancen);
}
if(*Huancen==35) //#
{
BIAOZHI(1,0,0);
}
if(*Huancen==80) //P
{
BIAOZHI(0,1,0);
}
if(*Huancen==84) //T
{
BIAOZHI(0,0,1);
}
Huancen++;
if(*Huancen==10)
{
if(Shujup>500)
{
*(Pwm+Shuju-1)=Shujup;//新的位置数据产生进行调度
}
return;
}
}
}
舵机程序数 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)