Facebook
From Zenobia, 9 Months ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 446
  1. #define LEFT_WHEELS_PORT 1
  2. #define RIGHT_WHEELS_PORT 10
  3. #define SPIN_PORT 3
  4.  
  5. void opcontrol() {
  6.   pros::Motor left_wheels (LEFT_WHEELS_PORT);
  7.   pros::Motor right_wheels (RIGHT_WHEELS_PORT, true);
  8.   pros::Motor arm (SPIN_PORT, MOTOR_GEARSET_36); // The arm motor has the 100rpm (red) gearset
  9.   pros::Controller master (CONTROLLER_MASTER);
  10.  
  11.   while (true) {
  12.     int power = master.get_analog(ANALOG_LEFT_Y);
  13.     int turn = master.get_analog(ANALOG_RIGHT_X);
  14.     int left = power + turn;
  15.     int right = power - turn;
  16.     left_wheels.move(left);
  17.     right_wheels.move(right);
  18.  
  19.     if (master.get_digital(DIGITAL_R1)) {
  20.       spin.move_velocity(600); // This is 600 because it's a 600rpm motor
  21.     }
  22.     else if (master.get_digital(DIGITAL_R2)) {
  23.       spin.move_velocity(-600);
  24.     }
  25.     else {
  26.       spin.move_velocity(0);
  27.     }
  28.  
  29.     pros::delay(2);
  30.   }
  31. }