View Full Version : Please Help Rookie with Simple Program
Please help me write Java program that will turn on and off a motor through Jaguar attached to PWM 3 on digital sidecar. I would like it to be mapped to button 4 on left joystick for on and button 5 on left joystick to turn it off. Please, please help
Thanks
Obot
Are you trying to send analog signals (-1.0 - 1.0)? or do you just want it to turn on and off like a relay?
Just turn on and off like a relay, Please.
You could do something simple like this:
import edu.wpi.first.wpilibj.*;
public class TestBot extends SimpleRobot {
private Joystick joystick1;
private Jaguar jag;
public void robotInit() {
joystick1 = new Joystick(1);
jag = new Jaguar(3);
Watchdog.getInstance();
}
public void autonomous() {
while (isAutonomous() && isEnabled()) {
getWatchdog().feed();
}
}
public void operatorControl() {
while (isOperatorControl() && isEnabled()) {
getWatchdog().feed();
boolean motorOn = false;
if(joystick1.getButton(4)) {
motorOn = true;
}
if(joystick1.getButton(5)) {
motorOn = false;
}
if(motorOn) {
jag.set(1.0);
} else {
jag.set(0.0);
}
Timer.delay(0.005);
}
}
public void disabled() {
while (isDisabled()) {
getWatchdog().feed();
}
}
}
Thanks Neal. I will try it!
austin1743
18-02-2012, 22:03
how did this work out for you guys?
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.