that_one_nigga_you_k

robô.segue linha

Jun 22nd, 2017
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. // definir a distância do objeto
  2.  
  3.  
  4. task main()
  5. {
  6. SetSensor(S2, SENSOR_COLORRED);
  7. SetSensor(S3, SENSOR_COLORRED);
  8. //SetSensorLowspeed(IN_1);
  9. // white==48; apenas para decorar
  10. // black==18;
  11.  
  12. while(true)
  13. {
  14.  
  15. if(Sensor(IN_2)>=48 && Sensor(IN_3)>=48) // ao ver branco, andar pra frente
  16. {
  17. OnFwd(OUT_AC, 75);
  18. Wait(100);
  19. }
  20.  
  21. else if(Sensor(IN_2)<=23 && Sensor(IN_3)>=48) // sensor 2, ao ver preto, desacelera lado DIREITO do robô
  22. {
  23. OnFwd(OUT_A, 1);
  24. OnFwd(OUT_C, 50);
  25. until(Sensor(IN_2)>25);
  26. }
  27.  
  28. else if(Sensor(IN_2)>=48 && Sensor(IN_3)<=23) // sensor 3, ao ver preto, desacelera lado ESQUERDO do robô
  29. {
  30. OnFwd(OUT_A, 50);
  31. OnFwd(OUT_C, 1);
  32. until(Sensor(IN_3)>25);
  33.  
  34. }
  35.  
  36. //else if(Sensor(IN_1)>20)
  37. //{
  38. //OnRev(OUT_AC, 75);
  39. //Wait (50);
  40. //}
  41.  
  42. }
  43.  
  44.  
  45. }
Add Comment
Please, Sign In to add comment