Keep in a box


hi i'm trying keep ardunio in box using; ir sensor array black border on paper.

currently ardunio recognise when there black line, motors not stop in time.

my program holds set of instructions , executes them based on r01_logo example sketch.

what happens check black line happens after execution example;
[move forwards] --> end --> [check black line] ---> [move forwards]

how stops black line has been detected, prefer use either robot.motorsstop(); or robot.waitcontinue();.


code: [select]
void forwards()
{
 thingtodo = 1; //move forwards
 int = 0;
 while (i < 11)
 {
 robot.motorswrite(100,100);
                 robot.updateir();
                
                
                  if(robot.irarray[3] < 400) //using 3rd test
                  {
                   //react blackline e.g. stop

                  }
                
 if (i == 10)
 {
 break;
 }
 i++;
 }
 thingtodo = 0; //stop moving
}


to test program using 3rd ir sensor instead of full array. have tested value output using serial window , returned numbers fine.

any appreciated, thank you.


other 10ms delay there nothing in code blocks.  problem somewhere else.  suggest post of code.



Arduino Forum > Using Arduino > Programming Questions > Keep in a box


arduino

Comments