Appendix
digitalWrite(pinRB,HIGH);
digitalWrite(pinRF,LOW);
digitalWrite(pinLB,LOW);
digitalWrite(pinLF,HIGH);
delay(e * 50);
}
void stopp(int f) //stop
{
digitalWrite(pinRB,HIGH);
digitalWrite(pinRF,HIGH);
digitalWrite(pinLB,HIGH);
digitalWrite(pinLF,HIGH);
delay(f * 100);
}
void back(int g) //back
{
digitalWrite(pinRB,HIGH);
digitalWrite(pinRF,LOW);
digitalWrite(pinLB,HIGH);
digitalWrite(pinLF,LOW);
delay(g * 300);
}
void detection() //test the distance of different direction
{
int delay_time = 250; //
ask_pin_F(); // read forward distance
if(Fspeedd < 10) // if distance less then 10
{
stopp(1);
back(2);
}
if(Fspeedd < 25) // if distance less then 10
{
stopp(1);
ask_pin_L();
delay(delay_time);
ask_pin_R();
delay(delay_time);
if(Lspeedd > Rspeedd) //if left distance more than right distance
{
directionn = Rgo;
}
if(Lspeedd <= Rspeedd)//if left distance not more than right
//distance
{
directionn = Lgo;
}
//if left if (Lspeedd < 10 && Rspeedd < 10) distance and right
//distance both less than 10
{
directionn = Bgo;
}
}
else
{
directionn = Fgo; // forward go
28
Need help?
Do you have a question about the TA0136 and is the answer not in the manual?