Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Please Help Rookie with Simple Program (http://www.chiefdelphi.com/forums/showthread.php?t=102944)

obot 15-02-2012 21:23

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

theNerd 15-02-2012 22:05

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?

obot 15-02-2012 22:10

Re: Please Help Rookie with Simple Program
 
Just turn on and off like a relay, Please.

neal 15-02-2012 22:14

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();
                }
        }

}


obot 15-02-2012 22:22

Re: Please Help Rookie with Simple Program
 
Thanks Neal. I will try it!

austin1743 18-02-2012 22:03

Re: Please Help Rookie with Simple Program
 
how did this work out for you guys?


All times are GMT -5. The time now is 06:45.

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