#include "NXCDefs.h"
task main(){
SetSensor(IN_1,SENSOR_TOUCH); //x1
SetSensor(IN_2,SENSOR_TOUCH); //x2
SetSensor(IN_3,SENSOR_TOUCH); //y1
SetSensor(IN_4,SENSOR_TOUCH); //y2
while(true){
//tempo pata chegar as bolinhas
Wait(5000);
// chegou as bolinhas
// 1 thread x
OnFwd(OUT_A, 60);
until (SENSOR_1 == 1);
Off(OUT_A);
Wait(100);
// 2 thread y
OnFwd(OUT_B, 60);// 2 thread
until (SENSOR_3 == 1);
Off(OUT_B);
Wait(100);
// 3 thread garra
//comunicação bluetooth - chegou carrinho
OnFwd(OUT_C, 60);
Wait(400);
Off(OUT_C);
Wait(100);
OnRev(OUT_C, 60);
Wait(400);
Off(OUT_C);
// 1 thread x - depois dar as bolinhas p o carrinho
OnRev(OUT_A, 60);
until (SENSOR_2 == 1);
Off(OUT_A);
Wait(100);
// 2 thread y - depois dar as bolinhas p o carrinho
OnRev(OUT_B, 60);// 2 thread
until (SENSOR_4 == 1);
Off(OUT_B);
Wait(100);
//Retoma o processo
}
}
Nenhum comentário:
Postar um comentário