that_one_nigga_you_k

whatevernigga.3.0

Jul 11th, 2017
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.93 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.  
  65. if(Sensor(IN_2)<=30 && Sensor(IN_3)<=30) //os dois sensores vendo preto
  66.  
  67. {
  68. OnFwd(OUT_AC, 75);
  69. }
  70.  
  71. else if(Sensor(IN_2)<=30) // sensor 2, ao ver preto, desacelera lado DIREITO do robô
  72. {
  73. OnRev(OUT_A, 50);
  74. OnFwd(OUT_C, 50);
  75. }
  76.  
  77. else if(Sensor(IN_3)<=30) // sensor 3, ao ver preto, desacelera lado ESQUERDO do robô
  78. {
  79. OnFwd(OUT_A, 50);
  80. OnRev(OUT_C, 50);
  81.  
  82. }
  83.  
  84. if(SensorUS(IN_1)<20)
  85. {
  86. RotateMotor(OUT_A, 75, 790); // forward 90 degrees
  87. RotateMotor(OUT_C, -75, 790);
  88. OnFwd(OUT_AC, 75);
  89. Wait(500);
  90.  
  91. RotateMotor(OUT_C, 75, 790);
  92. RotateMotor(OUT_A, -75, 790);
  93. OnFwd(OUT_AC, 75);
  94. Wait(500);
  95.  
  96. RotateMotor(OUT_C, 75, 790);
  97. RotateMotor(OUT_A, -75, 790);
  98. OnFwd(OUT_AC, 75);
  99. Wait(500);
  100.  
  101. RotateMotor(OUT_A, 75, 790); // forward 90 degrees
  102. RotateMotor(OUT_C, -75, 790);
  103. OnFwd(OUT_AC, 75);
  104. Wait(500);
  105. }
  106.  
  107. if (Sensor(IN_2) == 40 && Sensor(IN_3) == 40)
  108. {
  109. garra (60);
  110. }
  111.  
  112. }
  113.  
  114.  
  115. }
Add Comment
Please, Sign In to add comment