VikingRobotics
27-01-2013, 13:26
Salutations fellow programmers!
I'm the programmer for team 1989. This is my first year programming so I thought I'd reach out for a little help. Our team is going to have our shooter positioned at a fixed angle (36.8 degrees) and then we are going to vary the speed depending on our distance from the goals. I programmed 3 buttons on the attack 3 joystick for 3 different speeds but the motors for the shooter will only stay on when I am holding the button. I wanted to know if it is possible to program the buttons so that you push it once to turn the motors on and then push it again to turn them off. Nothing I've tried has worked so far. Here's the method I made for the shooter:
public void shooter()
{
final int button1 = 2;
final int button2 = 3;
final int button3 = 4;
double speed = 0;
if (leftstick.getRawButton(button1))//when button 2 is pressed motor moves at 30% of max speed
{
speed = 0.3;
}
if (leftstick.getRawButton(button2))//when button 3 is pressed motor moves at 60% of max speed
{
speed = 0.6;
}
if (leftstick.getRawButton(button3))//when button 4 is pressed motor moves at 90% of max speed
{
speed = 0.9;
}
Victor3.set(speed);
Victor4.set(speed);
}
I'm the programmer for team 1989. This is my first year programming so I thought I'd reach out for a little help. Our team is going to have our shooter positioned at a fixed angle (36.8 degrees) and then we are going to vary the speed depending on our distance from the goals. I programmed 3 buttons on the attack 3 joystick for 3 different speeds but the motors for the shooter will only stay on when I am holding the button. I wanted to know if it is possible to program the buttons so that you push it once to turn the motors on and then push it again to turn them off. Nothing I've tried has worked so far. Here's the method I made for the shooter:
public void shooter()
{
final int button1 = 2;
final int button2 = 3;
final int button3 = 4;
double speed = 0;
if (leftstick.getRawButton(button1))//when button 2 is pressed motor moves at 30% of max speed
{
speed = 0.3;
}
if (leftstick.getRawButton(button2))//when button 3 is pressed motor moves at 60% of max speed
{
speed = 0.6;
}
if (leftstick.getRawButton(button3))//when button 4 is pressed motor moves at 90% of max speed
{
speed = 0.9;
}
Victor3.set(speed);
Victor4.set(speed);
}