Go to Post The numbers that I gave were purely theoretical and should not be considered realistic - Karibou [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 15-02-2012, 21:23
obot obot is offline
Registered User
FRC #4181
 
Join Date: Feb 2012
Location: Blackduck
Posts: 5
obot is an unknown quantity at this point
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
Reply With Quote
  #2   Spotlight this post!  
Unread 15-02-2012, 22:05
theNerd's Avatar
theNerd theNerd is offline
Registered User
FRC #3329 (Cam Bots)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2110
Location: St. Marys
Posts: 51
theNerd is an unknown quantity at this point
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?
Reply With Quote
  #3   Spotlight this post!  
Unread 15-02-2012, 22:10
obot obot is offline
Registered User
FRC #4181
 
Join Date: Feb 2012
Location: Blackduck
Posts: 5
obot is an unknown quantity at this point
Re: Please Help Rookie with Simple Program

Just turn on and off like a relay, Please.
Reply With Quote
  #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
  #5   Spotlight this post!  
Unread 15-02-2012, 22:22
obot obot is offline
Registered User
FRC #4181
 
Join Date: Feb 2012
Location: Blackduck
Posts: 5
obot is an unknown quantity at this point
Re: Please Help Rookie with Simple Program

Thanks Neal. I will try it!
Reply With Quote
  #6   Spotlight this post!  
Unread 18-02-2012, 22:03
austin1743 austin1743 is offline
Head Programmer - Java
FRC #1743
Team Role: Programmer
 
Join Date: Feb 2011
Rookie Year: 2009
Location: Pennsylvania
Posts: 56
austin1743 is an unknown quantity at this point
Re: Please Help Rookie with Simple Program

how did this work out for you guys?
__________________
Team 1743
Head Programmer
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 07:59.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi