Guest User

Untitled

a guest
Mar 24th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.91 KB | None | 0 0
  1. #pragma config(I2C_Usage, I2C1, i2cSensors)
  2. #pragma config(Sensor, in1, leftLineFollower, sensorLineFollower)
  3. #pragma config(Sensor, in2, centerLineFollower, sensorLineFollower)
  4. #pragma config(Sensor, in3, rightLineFollower, sensorLineFollower)
  5. #pragma config(Sensor, in4, gyro, sensorGyro)
  6. #pragma config(Sensor, in6, armPot, sensorPotentiometer)
  7. #pragma config(Sensor, dgtl1, rightEncoder, sensorQuadEncoder)
  8. #pragma config(Sensor, dgtl3, leftEncoder, sensorQuadEncoder)
  9. #pragma config(Sensor, dgtl6, touchSensor, sensorTouch)
  10. #pragma config(Sensor, dgtl8, sonarSensor, sensorSONAR_cm)
  11. #pragma config(Sensor, I2C_1, rightIME, sensorQuadEncoderOnI2CPort, , AutoAssign )
  12. #pragma config(Sensor, I2C_2, leftIME, sensorQuadEncoderOnI2CPort, , AutoAssign )
  13. #pragma config(Sensor, I2C_3, armIME, sensorQuadEncoderOnI2CPort, , AutoAssign )
  14. #pragma config(Motor, port2, rightMotor, tmotorVex393_MC29, openLoop, reversed, driveRight, encoderPort, I2C_1)
  15. #pragma config(Motor, port3, leftMotor, tmotorVex393_MC29, openLoop, driveLeft, encoderPort, I2C_2)
  16. #pragma config(Motor, port6, armMotor, tmotorVex393_MC29, openLoop, reversed, encoderPort, I2C_3)
  17. //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
  18.  
  19. /*+++++++++++++++++++++++++++++++++++++++++++++| Notes |++++++++++++++++++++++++++++++++++++++++++++++
  20. 2 Joystick Drive
  21. - This program allows you to remotely control your robot using the USB Logitech Dual
  22. Action Joysticks.
  23. - For USB values to be transmitted to the robot, you must follow several steps:
  24. - Use the "#include "JoystickDriver.c"" line at the beginning of your program
  25. - Call the "getJoystickSettings(joystick);" in a loop to repeatedly retrieve the latest values
  26. - Open the Robot > Debugger Windows > "Joystick Control - Basic" window after downloading your
  27. program to the virtual robot
  28.  
  29. Robot Model(s): Squarebot
  30.  
  31. [I/O Port] [Name] [Type] [Description]
  32. Motor Port 2 rightMotor VEX Motor Right side motor
  33. Motor Port 3 leftMotor VEX Motor Left side motor
  34.  
  35. *To run this sample program on Swervebot, be sure to Reverse Motor Port 3 in the Motors and Sensors
  36. Setup, and to make sure that Motor Port 2 is NOT Reversed.
  37. ----------------------------------------------------------------------------------------------------*/
  38.  
  39. #pragma debuggerWindows("joystickSimple");
  40. #include "JoystickDriver.c"
  41.  
  42. task main()
  43. {
  44. //Loop Forever
  45. while(1 == 1)
  46. {
  47. //Get the Latest joystick values
  48. getJoystickSettings(joystick);
  49. //Set the driving motors equal to the Y-axis values of the joysticks
  50. motor[leftMotor] = joystick.joy1_y1;
  51. motor[rightMotor] = joystick.joy1_y2;
  52.  
  53. if(joy1Btn(6))
  54. {motor[armMotor]=40;}
  55. else if(joy1Btn(8))
  56. {motor[armMotor]=-40;}
  57. else
  58. {motor[armMotor]=0;}
  59.  
  60. }
  61. }
Add Comment
Please, Sign In to add comment