I am attempting to get a motor to spin using a joystick button. We figured it would be quite a simple task but the code we have doesn’t seem to work.
This is in our drive subsystem
public void elevatorSet(double x){
Robot.driveSubsystem.elevator.set(x);
}
This is in our drive with joysticks command
if(OI.upElevator.get()){
Robot.driveSubsystem.elevatorSet(1);
}
We already declared the talon that the motor is connected to and declared a new joystick button. It doesn’t even allow us to deploy code to the robot. Can someone explain what is incorrect?
Warning: I don’t code for my team at all.
Could it be a range error: you’re setting the elevator to 1, is the range for that function -1 to 1, or something else like 0 to 256 or -100 to 100?
Also assume good debugging procedures: make sure your battery is charged, test with a known working motor which doesn’t have any mechanisms attached to it, make sure your joystick is plugged in and reading, etc.
It could always be those pesky mechanicals or electricals ruining your perfectly good code (source: am a pesky mechanical and electrical constantly ruining perfectly good code)
We use the buttons as booleans. Example:
Joystick xbox = new Joystick(1)
Boolean xBoxButton1 = xbox.getRawButton(1);
if(xBoxButton1 == true){
//run motor
}