that_one_nigga_you_k

gbdusrg

Jul 5th, 2017
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. // definir a distância do objeto
  2. #define INPUT_REDCOLOR 5
  3. #define INPUT_GREENCOLOR 3
  4. #define INPUT_BLACKCOLOR 1
  5. #define INPUT_WHITECOLOR 6
  6.  
  7. //inline garra;
  8. // {
  9.  
  10. // if(Sensor(IN_4) > 10)
  11. //{
  12. // OnFwd(OUT_B, 75)
  13. // }
  14.  
  15. // }
  16.  
  17.  
  18. task main()
  19. {
  20. SetSensor(S2, SENSOR_COLORRED);
  21. SetSensor(S3, SENSOR_COLORRED);
  22. SetSensorLowspeed(IN_1);
  23. SetSensorLowspeed(IN_4);
  24. //white==48; apenas para decorar
  25. // black==18;
  26. //green==18;
  27.  
  28. while(true)
  29. {
  30.  
  31. if(Sensor(IN_2)>=30 && Sensor(IN_3)>=30) // ao ver branco, andar pra frente
  32. {
  33. OnFwd(OUT_AC, 75);
  34. }
  35.  
  36. else if(Sensor(IN_2)<=30) // sensor 2, ao ver preto, desacelera lado DIREITO do robô
  37. {
  38. OnRev(OUT_A, 50);
  39. OnFwd(OUT_C, 50);
  40. }
  41.  
  42. else if(Sensor(IN_3)<=30) // sensor 3, ao ver preto, desacelera lado ESQUERDO do robô
  43. {
  44. OnFwd(OUT_A, 50);
  45. OnRev(OUT_C, 50);
  46.  
  47. }
  48.  
  49. if(SensorUS(IN_1)<=20)
  50. {
  51. RotateMotor(OUT_C, 75, 90); // forward 90 degrees
  52. OnFwd(OUT_AC, 75);
  53. Wait(500);
  54. RotateMotor(OUT_A, 75, 90);
  55. OnFwd(OUT_AC, 75);
  56. Wait(500);
  57. RotateMotor(OUT_A, 75, 90);
  58. OnFwd(OUT_AC, 75);
  59. Wait(500);
  60. RotateMotor(OUT_C, 75, 90); // forward 90 degrees
  61. OnFwd(OUT_AC, 75);
  62. Wait(500);
  63. }
  64.  
  65. }
  66.  
  67.  
  68. }
Add Comment
Please, Sign In to add comment