View Single Post
  #4   Spotlight this post!  
Unread 15-02-2012, 22:14
neal's Avatar
neal neal is offline
Neal
FRC #1777 (Viking Robotics)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2009
Location: United States
Posts: 56
neal is an unknown quantity at this point
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();
		}
	}

}
Reply With Quote