that_one_nigga_you_k

parte_de_baixo_da_arena.ncx

Jul 6th, 2017
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 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. // rotatemotor(OUT_B, 75, 90);
  13. //
  14. // }
  15.  
  16. // }
  17.  
  18.  
  19. task main()
  20. {
  21. SetSensor(S2, SENSOR_COLORRED);
  22. SetSensor(S3, SENSOR_COLORRED);
  23. SetSensorLowspeed(IN_1);
  24. SetSensorLowspeed(IN_4);
  25. //white==48; apenas para decorar
  26. // black==18;
  27. //green==18;
  28.  
  29. while(true)
  30. {
  31.  
  32. if(Sensor(IN_2)>=30 && Sensor(IN_3)>=30) // ao ver branco, andar pra frente
  33. {
  34. OnFwd(OUT_AC, 75);
  35. }
  36.  
  37. else if(Sensor(IN_2)<=30) // sensor 2, ao ver preto, desacelera lado DIREITO do robô
  38. {
  39. OnRev(OUT_A, 50);
  40. OnFwd(OUT_C, 50);
  41. }
  42.  
  43. else if(Sensor(IN_3)<=30) // sensor 3, ao ver preto, desacelera lado ESQUERDO do robô
  44. {
  45. OnFwd(OUT_A, 50);
  46. OnRev(OUT_C, 50);
  47.  
  48. }
  49.  
  50. else if(Sensor(IN_2)<=30 && Sensor(IN_3)<=30) //os dois sensores vendo preto
  51.  
  52. {
  53. OnFwd(OUT_AC, 75);
  54. }
  55.  
  56. if(SensorUS(IN_1)<20)
  57. {
  58. RotateMotor(OUT_A, 75, 790); // forward 90 degrees
  59. RotateMotor(OUT_C, -75, 790);
  60. OnFwd(OUT_AC, 75);
  61. Wait(500);
  62.  
  63. RotateMotor(OUT_C, 75, 790);
  64. RotateMotor(OUT_A, -75, 790);
  65. OnFwd(OUT_AC, 75);
  66. Wait(500);
  67.  
  68. RotateMotor(OUT_C, 75, 790);
  69. RotateMotor(OUT_A, -75, 790);
  70. OnFwd(OUT_AC, 75);
  71. Wait(500);
  72.  
  73. RotateMotor(OUT_A, 75, 790); // forward 90 degrees
  74. RotateMotor(OUT_C, -75, 790);
  75. OnFwd(OUT_AC, 75);
  76. Wait(500);
  77. }
  78.  
  79. }
  80.  
  81.  
  82. }
Add Comment
Please, Sign In to add comment