Skip to content

Instantly share code, notes, and snippets.

@joelgallant
Created February 12, 2013 01:07
Show Gist options
  • Save joelgallant/4759152 to your computer and use it in GitHub Desktop.
Save joelgallant/4759152 to your computer and use it in GitHub Desktop.
package testing;
import edu.wpi.first.wpilibj.Jaguar;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.SimpleRobot;
import edu.wpi.first.wpilibj.Timer;
public class Robot extends SimpleRobot {
Joystick joystick = new Joystick(1);
RobotDrive drive = new RobotDrive(1, 2, 3, 4);
Jaguar jag1 = new Jaguar(1),
jag2 = new Jaguar(2);
public void operatorControl() {
while(isOperatorControl() && isEnabled()) {
// CHANGE THESE TO THE PORTS YOU NEED
final int CLOCKWISE = 1;
final int COUNTER_CLOCKWISE = 2;
final int FORWARD = 1;
final int TURNING = 2;
jag1.set(joystick.getRawButton(CLOCKWISE) ? 1 : (joystick.getRawButton(COUNTER_CLOCKWISE) ? -1 : 0));
jag2.set(joystick.getRawButton(CLOCKWISE) ? 1 : (joystick.getRawButton(COUNTER_CLOCKWISE) ? -1 : 0));
drive.arcadeDrive(joystick.getRawAxis(FORWARD), joystick.getRawAxis(TURNING));
Timer.delay(0.02);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment