Go to Post A Guru teaching batteries at Exide: "Do not draw your power from up here, by your terminals. You must reach down deep into your plates and pull the energy from your entire being! You must prove yourself worthy to be FIRST power cells!" - KenWittlief [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 19-03-2012, 15:31
kinganu123 kinganu123 is offline
Registered User
FRC #1747
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Piscataway, NJ
Posts: 243
kinganu123 is on a distinguished road
Re: Need serious help with coding!!

a basic code would be
Code:
if(joystick.getRawButton(4)
     jaguar.set(1);
else if(joystick.getRawButton(5)
     jaguar.set(-1);
else
     jaguar.set(0);
__________________
Reply With Quote
  #2   Spotlight this post!  
Unread 19-03-2012, 15:41
Sconrad Sconrad is offline
Registered User
AKA: Connor Young
FRC #0122 (NASA Knights)
Team Role: Programmer
 
Join Date: Oct 2011
Rookie Year: 2011
Location: Yorktown
Posts: 40
Sconrad is an unknown quantity at this point
Re: Need serious help with coding!!

Quote:
Originally Posted by kinganu123 View Post
a basic code would be
Code:
if(joystick.getRawButton(4)
     jaguar.set(1);
else if(joystick.getRawButton(5)
     jaguar.set(-1);
else
     jaguar.set(0);
Note: This will not create a toggle effect. If 4 is pressed, the motor will go forward and if 5 is pressed the motor will go in reverse, but it will not continue to go in that direction if you let go of the button. However, this is a good, simple solution to the problem you are facing. One thing to note about how this code will perform, if both buttons are pressed, the jaguar will go forward. One way to fix this is to replace the first line with
Code:
if(joystick.getRawButton(4) && !joystick.getRawButton(5))
It is a little bit longer, but will protect you from accidentally going in the wrong direction should you hit both buttons in the heat of competition. In order to have a true toggle effect, you will probably need a limit switch or potentiometer or other sensor to tell you when you are done going up or done going down. Hope this helps!
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 10:06.

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