that_one_nigga_you_k

então toma

Jul 12th, 2017
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.31 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.  
  8. /*
  9.  
  10. sub garra (int pwr)
  11. {
  12.  
  13. while(true)
  14. {
  15. if(Sensor(IN_2)<=30 && Sensor(IN_3)<=30)
  16. {
  17. OnFwd(OUT_AC, 75);
  18. }
  19.  
  20. else if(SensorUS(IN_1)<10)
  21. {
  22. RotateMotor(OUT_C, 75, 600);
  23. OnRev(OUT_AC, 75);
  24. }
  25.  
  26. else if(SensorUS(IN_4)<7)
  27. {
  28. RotateMotor(OUT_B, 75, 50);
  29. RotateMotor(OUT_A, 75, 600);
  30. OnFwd(OUT_AC, 75);
  31. }
  32. }
  33.  
  34.  
  35. }
  36. */
  37.  
  38.  
  39. task main()
  40. {
  41. SetSensor(S2, SENSOR_COLORRED);
  42. SetSensor(S3, SENSOR_COLORRED);
  43. SetSensorLowspeed(IN_1);
  44. SetSensorLowspeed(IN_4);
  45. //white==48; apenas para decorar
  46. // black==18;
  47. //green==18;
  48.  
  49. while(true)
  50. {
  51.  
  52. if(Sensor(IN_2)>=30 && Sensor(IN_3)>=30) // ao ver branco, andar pra frente
  53. {
  54. OnFwd(OUT_AC, 65);
  55.  
  56. if(SensorUS(IN_1)<7) // distancia para a virada
  57. {
  58. OnFwd(OUT_C, 65); // forward 90 degrees
  59. OnRev(OUT_A, 65);
  60. Wait(860);
  61. OnFwd(OUT_AC, 65);
  62. Wait(2230);
  63. OnFwd(OUT_A, 65);
  64. OnRev(OUT_C, 65);
  65. Wait(1500);
  66. OnFwd(OUT_AC, 65);
  67. Wait(1000);
  68. //OnFwd(OUT_A, 65);
  69. //OnRev(OUT_C, 65);
  70. //Wait(1500);
  71. //OnFwd(OUT_AC, 65);
  72.  
  73. if(Sensor(IN_2)>=30 && Sensor(IN_3)>=30)
  74. {
  75. OnFwd(OUT_C, 65); // forward 90 degrees
  76. OnRev(OUT_A, 65);
  77. }
  78. }
  79.  
  80. }
  81.  
  82. else if(Sensor(IN_2)<=30 && Sensor(IN_3)<=30) //os dois sensores vendo preto
  83. {
  84. OnRev(OUT_AC, 65);
  85. Wait(500);
  86. OnFwd(OUT_AC, 65);
  87.  
  88. SetSensor(S2, SENSOR_COLORFULL); //transforma os sensores de luz em sensor de cor
  89. SetSensor(S3, SENSOR_COLORFULL);
  90. SetSensorLowspeed(IN_1);
  91. SetSensorLowspeed(IN_4);
  92.  
  93. if(Sensor(IN_2) == 3) //DIREITA vendo verde
  94. {
  95. OnRev(OUT_A, 50);
  96. OnFwd(OUT_C, 50);
  97. }
  98.  
  99. else if(Sensor(IN_3) == 3) // ESQUERDA vendo verde
  100. {
  101. OnRev(OUT_C, 50);
  102. OnFwd(OUT_A, 50);
  103. }
  104.  
  105. }
  106.  
  107. else if(Sensor(IN_2)<=30) // sensor 2, ao ver preto, desacelera lado DIREITO do robô
  108. {
  109. OnFwd(OUT_C, 50);
  110. OnRev(OUT_A, 50);
  111. }
  112.  
  113. else if(Sensor(IN_3)<=30) // sensor 3, ao ver preto, desacelera lado ESQUERDO do robô
  114. {
  115. OnFwd(OUT_A, 50);
  116. OnRev(OUT_C, 50);
  117.  
  118. }
  119.  
  120.  
  121.  
  122. /*if (Sensor(IN_2) == 40 && Sensor(IN_3) == 40)
  123. {
  124. garra (60);
  125. }
  126. */
  127. }
  128. }
Add Comment
Please, Sign In to add comment