Advertisement
Guest User

Untitled

a guest
Feb 27th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.89 KB | None | 0 0
  1. #pragma config(Motor, port1, leftMotor, tmotorVex393_HBridge, openLoop, reversed)
  2. #pragma config(Motor, port6, clawMotor, tmotorVex393_MC29, openLoop)
  3. #pragma config(Motor, port7, armMotor, tmotorVex393_MC29, openLoop)
  4. #pragma config(Motor, port10, rightMotor, tmotorVex393_HBridge, openLoop)
  5. //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
  6.  
  7. /*----------------------------------------------------------------------------------------------------*\
  8. |* - Clawbot Single Joystick Control - *|
  9. |* ROBOTC on VEX 2.0 Cortex *|
  10. |* *|
  11. |* This program uses a single joystick, either right or left to drive the robot. Use notes below *|
  12. |* to reconfigure which joystick is used. The joystick buttons are used to raise and lower the arm. *|
  13. |* The joystick buttons are used to open and close the claw. *|
  14. |* *|
  15. |* ROBOT CONFIGURATION *|
  16. |* NOTES: *|
  17. |* 1) Ch1 is the X axis and Ch2 is the Y axis for the RIGHT joystick. *|
  18. |* 2) Ch3 is the Y axis and Ch4 is the X axis for the LEFT joystick. *k|
  19. |* 3) Button 5U and 5L are on the front left side of the joystick. *|
  20. |* 3) Button 6U and 6L are on the front right side of the joystick. *|
  21. |* *|
  22. |* MOTORS & SENSORS: *|
  23. |* [I/O Port] [Name] [Type] [Description] *|
  24. |* Motor - Port 2 rightMotor VEX 393 Motor Right drive motor *|
  25. |* Motor - Port 6 clawMotor VEX 393 Motor w/ Motor Controler 29 Claw motor *|
  26. |* Motor - Port 7 armMotor VEX 393 Motor w/ Motor Controler 29 Arm motor *|
  27. |* Motor - Port 10 leftMotor VEX 393 Motor Left drive motor *|
  28. \*----------------------------------------------------------------------------------------------------*/
  29.  
  30. //+++++++++++++++++++++++++++++++++++++++++++++| MAIN |+++++++++++++++++++++++++++++++++++++++++++++++
  31. task main ()
  32. {
  33.  
  34. while(1 == 1)
  35. {
  36. /* motor[leftMotor] = (vexRT[Ch2] + vexRT[Ch3])/2; // (y + x)/2
  37. motor[rightMotor] = (vexRT[Ch2] - vexRT[Ch3])/2; // (y - x)/2 */
  38.  
  39. motor[leftMotor] = vexRT[Ch3] * 0.7;
  40. motor[rightMotor] = vexRT[Ch2] * 0.7;
  41.  
  42. // Raise, lower or do not move arm
  43. if(vexRT[Btn6U] == 1) //If button 6U is pressed...
  44. {
  45. motor[armMotor] = -50; //...raise the arm.
  46. }
  47. else if(vexRT[Btn6D] == 1) //Else, if button 6D is pressed...
  48. {
  49. motor[armMotor] = 50; //...lower the arm.
  50. }
  51. else //Else (neither button is pressed)...
  52. {
  53. motor[armMotor] = 0; //...stop the arm.
  54. }
  55.  
  56. // Open, close or do not more claw
  57. if(vexRT[Btn5D] == 1) //If Button 6U is pressed...
  58. {
  59. motor[clawMotor] = 50; //...close the gripper.
  60. }
  61. else if(vexRT[Btn5U] == 1) //Else, if button 6D is pressed...
  62. {
  63. motor[clawMotor] = -50; //...open the gripper.
  64. }
  65. else //Else (neither button is pressed)...
  66. {
  67. motor[clawMotor] = 0; //...stop the gripper.
  68. }
  69. }
  70. }
  71. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement