Advertisement
p_judge

VEX TESTING 4

Dec 12th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.29 KB | None | 0 0
  1. #include "main.h"
  2.  
  3. /**
  4. * A callback function for LLEMU's center button.
  5. *
  6. * When this callback is fired, it will toggle line 2 of the LCD text between
  7. * "I was pressed!" and nothing.
  8. */
  9. void on_center_button() {}
  10.  
  11. /**
  12. * Runs initialization code. This occurs as soon as the program is started.
  13. *
  14. * All other competition modes are blocked by initialize; it is recommended
  15. * to keep execution time for this mode under a few seconds.
  16. */
  17. void initialize() {
  18.  
  19. }
  20.  
  21. /**
  22. * Runs while the robot is in the disabled state of Field Management System or
  23. * the VEX Competition Switch, following either autonomous or opcontrol. When
  24. * the robot is enabled, this task will exit.
  25. */
  26. void disabled() {}
  27.  
  28. /**
  29. * Runs after initialize(), and before autonomous when connected to the Field
  30. * Management System or the VEX Competition Switch. This is intended for
  31. * competition-specific initialization routines, such as an autonomous selector
  32. * on the LCD.
  33. *
  34. * This task will exit when the robot is enabled and autonomous or opcontrol
  35. * starts.
  36. */
  37. void competition_initialize() {}
  38.  
  39. /**
  40. * Runs the user autonomous code. This function will be started in its own task
  41. * with the default priority and stack size whenever the robot is enabled via
  42. * the Field Management System or the VEX Competition Switch in the autonomous
  43. * mode. Alternatively, this function may be called in initialize or opcontrol
  44. * for non-competition testing purposes.
  45. *
  46. * If the robot is disabled or communications is lost, the autonomous task
  47. * will be stopped. Re-enabling the robot will restart the task, not re-start it
  48. * from where it left off.
  49. */
  50. void autonomous() {}
  51.  
  52. /**
  53. * Runs the operator control code. This function will be started in its own task
  54. * with the default priority and stack size whenever the robot is enabled via
  55. * the Field Management System or the VEX Competition Switch in the operator
  56. * control mode.
  57. *
  58. * If no competition control is connected, this function will run immediately
  59. * following initialize().
  60. *
  61. * If the robot is disabled or communications is lost, the
  62. * operator control task will be stopped. Re-enabling the robot will restart the
  63. * task, not resume it from where it left off.
  64. */
  65. void opcontrol() {
  66.  
  67. pros::Motor front_r(20);
  68. pros::Motor front_l(19);
  69. pros::Motor back_r(14);
  70. pros::Motor back_l(13);
  71.  
  72.  
  73. pros:: Motor left_mtr(2);
  74. pros:: Motor right_mtr(3);
  75. pros::Motor lift_mtr (1);
  76. pros::Motor pivot_mtr (4);
  77. pros::Controller master(pros::E_CONTROLLER_MASTER);
  78.  
  79. /*
  80.  
  81. //intake
  82. if (master.get_digital(pros::E_CONTROLLER_DIGITAL_R1) == 1)
  83. {
  84. left_mtr.move(-120);
  85. right_mtr.move(120);
  86. pros::delay(20);
  87. }
  88.  
  89. while (master.get_digital(pros::E_CONTROLLER_DIGITAL_R2) == 1)
  90. {
  91. left_mtr.move(120);
  92. right_mtr.move(-120);
  93. pros::delay(20);
  94. }
  95. if (pros::E_CONTROLLER_DIGITAL_R1 == 1 && pros::E_CONTROLLER_DIGITAL_R2 == 1)
  96. {
  97.  
  98. left_mtr.move(120);
  99. right_mtr.move(-120);
  100. pros::delay(0);
  101.  
  102. }
  103.  
  104.  
  105.  
  106. */
  107. //lift
  108.  
  109.  
  110. while (true){
  111. //////////////////////////////LIFT//////////////////////////////
  112. if(master.get_digital(pros::E_CONTROLLER_DIGITAL_X))
  113. {
  114. lift_mtr.move(-70);
  115. pros::delay(10);
  116. }
  117. else
  118. {
  119. lift_mtr.move(0);
  120. pros::delay(10);
  121. }
  122.  
  123. if (master.get_digital(pros::E_CONTROLLER_DIGITAL_B))
  124. {
  125. lift_mtr.move(70);
  126. pros::delay(10);
  127. }
  128. else
  129. {
  130. lift_mtr.move(0);
  131. pros::delay(10);
  132. }
  133.  
  134.  
  135. //////////////////////////////LIFT//////////////////////////////
  136. //////////////////////////////INTAKE//////////////////////////////
  137. if (master.get_digital(pros::E_CONTROLLER_DIGITAL_R1) == 1)
  138. {
  139. left_mtr.move(-120);
  140. right_mtr.move(120);
  141. pros::delay(20);
  142. }
  143. else
  144. {
  145. left_mtr.move(0);
  146. right_mtr.move(0);
  147. pros::delay(10);
  148. }
  149.  
  150.  
  151. if (master.get_digital(pros::E_CONTROLLER_DIGITAL_R2) == 1)
  152. {
  153. left_mtr.move(120);
  154. right_mtr.move(-120);
  155. pros::delay(20);
  156. }
  157. else
  158. {
  159. left_mtr.move(0);
  160. right_mtr.move(0);
  161. pros::delay(10);
  162. }
  163.  
  164. //////////////////////////////INTAKE//////////////////////////////
  165. //////////////////////////////PIVOT ARM//////////////////////////////
  166. if (master.get_digital(pros::E_CONTROLLER_DIGITAL_DOWN) == 1)
  167. {
  168. pivot_mtr.move(-100);
  169. pros::delay(20);
  170. }
  171.  
  172. else
  173. {
  174. pivot_mtr.move(0);
  175. pros::delay(20);
  176. }
  177.  
  178. if (master.get_digital(pros::E_CONTROLLER_DIGITAL_UP) == 1) {
  179. pivot_mtr.move(100);
  180. pros::delay(20);
  181. }
  182.  
  183. else {
  184. pivot_mtr.move(0);
  185. pros::delay(20);
  186. }
  187. //////////////////////////////PIVOT ARM//////////////////////////////
  188.  
  189. //arms
  190.  
  191. if (master.get_digital(pros::E_CONTROLLER_DIGITAL_DOWN) == 1) {
  192. pivot_mtr.move(-100);
  193. pros::delay(20);
  194. }
  195.  
  196. else {
  197. pivot_mtr.move(0);
  198. pros::delay(20);
  199.  
  200. }
  201.  
  202. if (master.get_digital(pros::E_CONTROLLER_DIGITAL_UP) == 1) {
  203. pivot_mtr.move(100);
  204. pros::delay(20);
  205. }
  206.  
  207. else {
  208. pivot_mtr.move(0);
  209. pros::delay(20);
  210. }
  211.  
  212.  
  213.  
  214. ///////////////////////DRIVE////////////////////////////////
  215.  
  216. int left = master.get_analog(ANALOG_LEFT_Y);
  217. int right = master.get_analog(ANALOG_RIGHT_Y);
  218. front_r = -right;
  219. back_r = -right;
  220. front_l = left;
  221. back_l = left;
  222.  
  223. pros::delay(20);
  224. ///////////////////////////////////////////////////////
  225. }
  226. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement