Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // definir a distância do objeto
- task main()
- {
- SetSensor(S2, SENSOR_COLORRED);
- SetSensor(S3, SENSOR_COLORRED);
- //SetSensorLowspeed(IN_1);
- // white==48; apenas para decorar
- // black==18;
- while(true)
- {
- if(Sensor(IN_2)>=48 && Sensor(IN_3)>=48) // ao ver branco, andar pra frente
- {
- OnFwd(OUT_AC, 75);
- Wait(100);
- }
- else if(Sensor(IN_2)<=23 && Sensor(IN_3)>=48) // sensor 2, ao ver preto, desacelera lado DIREITO do robô
- {
- OnFwd(OUT_A, 1);
- OnFwd(OUT_C, 50);
- until(Sensor(IN_2)>25);
- }
- else if(Sensor(IN_2)>=48 && Sensor(IN_3)<=23) // sensor 3, ao ver preto, desacelera lado ESQUERDO do robô
- {
- OnFwd(OUT_A, 50);
- OnFwd(OUT_C, 1);
- until(Sensor(IN_3)>25);
- }
- //else if(Sensor(IN_1)>20)
- //{
- //OnRev(OUT_AC, 75);
- //Wait (50);
- //}
- }
- }
Add Comment
Please, Sign In to add comment