智能车制作

标题: 求大神帮忙解读 [打印本页]

作者: zgs9199591995    时间: 2014-5-15 20:36
标题: 求大神帮忙解读
void Get_Direction()
{
    int q;

    TSL1401_GetLine(gPixel);
    Get_Threshold();

    for(q=64;q<128;q++)
    {
       if(gPixel[q]<THRESHOLD&&gPixel[q+4]<THRESHOLD)
       {

          y=q;
          q=128;
       }
       else y=256;
    }


   for(q=64;q>0;q--)
   {
      if(gPixel[q]<THRESHOLD&&gPixel[q-4]<THRESHOLD)
      {  
          x=q;
          q=0;
      }
       else x=256;
    }

     if(x!=256&&y!=256)
        Direction_Value=(x+y)/2-64;
    if(x==256&&y!=256)                    //右侧有黑线
       Direction_Value=y-128;

    if(x!=256&&y==256)                    //左侧有黑线
       Direction_Value=x;

    if(x==256&&y==256)
        Direction_Value=0;
}



补充内容 (2014-5-17 20:43):
问题已解决




欢迎光临 智能车制作 (http://111.231.132.190/) Powered by Discuz! X3.2