wallgentle.ic
void Wallgentle(){
int pid1; // Espera precionar start antes de comecar sleep(0.5); printf ("\nSeguir Parede"); while(!start_button()); sleep(0.5); pid1 = start_process(WallFollow2()); while(!stop_button()); kill_process(pid1); ao();
}
void WallFollow2(){
int sensor; int estado = ESQ; LEFT_POWER = 30; RIGHT_POWER = 30; // Define o estado inicial VirarEsq2(); estado = ESQ; while (1){ sensor = analog(SENSOR); if (sensor < perto){ VirarDir2(); } else{ VirarEsq2(); } }
}
Vira para direita void VirarDir2(){ motor (LEFT_MOTOR, (int)1); motor (RIGHT_MOTOR, 0); } Vira para esquerda void VirarEsq2(){
motor (LEFT_MOTOR, 0); motor (RIGHT_MOTOR, (int)((float)RIGHT_POWER*0.5));
}
1)
float)LEFT_POWER*0.5