that_one_nigga_you_k

whatevernigga.4.0

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