|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
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 |
|
#2
|
||||
|
||||
|
Re: Please Help Rookie with Simple Program
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?
|
|
#3
|
|||
|
|||
|
Re: Please Help Rookie with Simple Program
Just turn on and off like a relay, Please.
|
|
#4
|
||||
|
||||
|
Re: Please Help Rookie with Simple Program
You could do something simple like this:
Code:
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();
}
}
}
|
|
#5
|
|||
|
|||
|
Re: Please Help Rookie with Simple Program
Thanks Neal. I will try it!
|
|
#6
|
|||
|
|||
|
Re: Please Help Rookie with Simple Program
how did this work out for you guys?
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|