Guest User

Untitled

a guest
Jul 19th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.51 KB | None | 0 0
  1. #pragma config(Hubs, S1, HTMotor, HTMotor, HTServo, none)
  2. #pragma config(Motor, motorA, motorLeftArm, tmotorNormal, PIDControl, encoder)
  3. #pragma config(Motor, motorB, motorRightArm, tmotorNormal, PIDControl, encoder)
  4. #pragma config(Motor, motorC, motorBucketSpinner, tmotorNormal, PIDControl, encoder)
  5. #pragma config(Motor, mtr_S1_C1_1, motorShooter, tmotorNormal, openLoop)
  6. #pragma config(Motor, mtr_S1_C1_2, motorBucket, tmotorNormal, openLoop)
  7. #pragma config(Motor, mtr_S1_C2_1, motorRight, tmotorNormal, openLoop)
  8. #pragma config(Motor, mtr_S1_C2_2, motorLeft, tmotorNormal, openLoop)
  9. #pragma config(Servo, srvo_S1_C3_1, servoBucketLock, tServoNormal)
  10. #pragma config(Servo, srvo_S1_C3_2, servoBallLock, tServoNormal)
  11. //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
  12.  
  13. #include "JoystickDriver.c"
  14.  
  15. #define JOY1_BUTTON(x) joystick.joy1_Buttons >> x-1 & 0x1
  16.  
  17. void initializeRobot()
  18. {
  19. return;
  20. }
  21.  
  22. void autonomous()
  23. {
  24. StopAllTasks();
  25. }
  26.  
  27. void teleop()
  28. {
  29. /* Reset motors */
  30. motor[motorA] = 0;
  31. motor[motorB] = 0;
  32. motor[motorC] = 0;
  33. motor[motorD] = 0;
  34. motor[motorE] = 0;
  35. motor[motorF] = 0;
  36. motor[motorG] = 0;
  37.  
  38. /* Reset servos */
  39. servo[servoBucketLock] = 255;
  40. servo[servoBallLock] = 6;
  41.  
  42. while (1) {
  43. alive();
  44. getJoystickSettings(joystick);
  45.  
  46. /* Left motor */
  47. if (joystick.joy1_y1 > 20) {
  48. motor[motorLeft] = 100;
  49. } else if (joystick.joy1_y1 < -20) {
  50. motor[motorLeft] = -100;
  51. } else {
  52. motor[motorLeft] = 0;
  53. }
  54.  
  55. /* Right motor */
  56. if (joystick.joy1_y2 > 20) {
  57. motor[motorRight] = -100;
  58. } else if (joystick.joy1_y2 < -20) {
  59. motor[motorRight] = 100;
  60. } else {
  61. motor[motorRight] = 0;
  62. }
  63.  
  64. /* Ball shooter */
  65. if (JOY1_BUTTON(1) == 1) {
  66. /* Backwards */
  67. motor[motorShooter] = 255;
  68. } else if (JOY1_BUTTON(3) == 1) {
  69. /* Forwards */
  70. motor[motorShooter] = -255;
  71. } else {
  72. motor[motorShooter] = 0;
  73. }
  74.  
  75. /* Ball box */
  76. if (JOY1_BUTTON(4) == 1) {
  77. /* Up */
  78. motor[motorBucket] = 255;
  79. wait1Msec(10);
  80. motor[motorBucket] = 0;
  81. } else if (JOY1_BUTTON(2) == 1) {
  82. /* Down */
  83. motor[motorBucket] = -255;
  84. wait1Msec(10);
  85. motor[motorBucket] = 0;
  86. }
  87.  
  88. /* Left arm */
  89. if (JOY1_BUTTON(5) == 1) {
  90. /* In */
  91. motor[motorLeftArm] = -255;
  92. wait1Msec(300);
  93. motor[motorLeftArm] = 0;
  94. } else if (JOY1_BUTTON(7) == 1) {
  95. /* Out */
  96. motor[motorLeftArm] = 255;
  97. wait1Msec(300);
  98. motor[motorLeftArm] = 0;
  99. }
  100.  
  101. /* Right arm */
  102. if (JOY1_BUTTON(6) == 1) {
  103. /* In */
  104. motor[motorRightArm] = -255;
  105. wait1Msec(300);
  106. motor[motorRightArm] = 0;
  107. } else if (JOY1_BUTTON(8) == 1) {
  108. /* Out */
  109. motor[motorRightArm] = 255;
  110. wait1Msec(300);
  111. motor[motorRightArm] = 0;
  112. }
  113.  
  114. /* Bucket thing */
  115. if (JOY1_BUTTON(9) == 1) {
  116. /* On */
  117. motor[motorBucketSpinner] = 100;
  118. } else if (JOY1_BUTTON(10) == 1) {
  119. /* Off */
  120. motor[motorBucketSpinner] = 0;
  121. }
  122.  
  123. if (joystick.joy1_TopHat == 0 ) {
  124. servo[servoBucketLock] = 160;
  125. }
  126.  
  127. if (joystick.joy1_TopHat == 4 ) {
  128. servo[servoBucketLock] = 255;
  129. }
  130.  
  131. if (joystick.joy1_TopHat == 2 ) {
  132. servo[servoBallLock] = 6;
  133. }
  134.  
  135. if (joystick.joy1_TopHat == 6 ) {
  136. servo[servoBallLock] = 128;
  137. }
  138. }
  139. }
  140.  
  141. task main()
  142. {
  143. initializeRobot();
  144.  
  145. waitForStart();
  146.  
  147. if (joystick.UserMode) {
  148. teleop();
  149. } else {
  150. autonomous();
  151. }
  152. }
Add Comment
Please, Sign In to add comment