Go to Post I believe you have the right to develope your own opinion. I would suggest it be based on actual experience and facts. - Mike Copioli [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 06-02-2008, 21:01
program1's Avatar
program1 program1 is offline
Registered User
AKA: RJ
FRC #2441
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Maryknoll
Posts: 43
program1 will become famous soon enough
button control

im trying to activate moters for a certain amount of time with a press of a button on the joystick. how do you make a button code?
__________________
ok, who ate my hot pocket?

Last edited by program1 : 06-02-2008 at 21:12.
  #2   Spotlight this post!  
Unread 06-02-2008, 21:17
eaglesfan10's Avatar
eaglesfan10 eaglesfan10 is offline
Registered User
FRC #1647 (Iron Devils)
Team Role: Programmer
 
Join Date: Oct 2007
Rookie Year: 2005
Location: New Jersey
Posts: 19
eaglesfan10 is an unknown quantity at this point
Re: button control

You could set a flag and use a counter. It would probably look something like this:
static int flag = 0;
static int counter = 0;

if(button_pressed)
{
flag = 1;
}

if(flag && counter < some_number)
{
//your code
}
else
{
flag = 0;
counter = 0;
}
counter++;
I'm probably missing something, but that's the general idea. I think there are about 40 loop counts in one second.
  #3   Spotlight this post!  
Unread 06-02-2008, 21:25
Alexa Stott's Avatar
Alexa Stott Alexa Stott is offline
All I do is twin.
AKA: elixir
FRC #0025 (Raider Robotix)
Team Role: College Student
 
Join Date: Oct 2005
Rookie Year: 2006
Location: No. Bruns., NJ/College Park, MD
Posts: 781
Alexa Stott has a reputation beyond reputeAlexa Stott has a reputation beyond reputeAlexa Stott has a reputation beyond reputeAlexa Stott has a reputation beyond reputeAlexa Stott has a reputation beyond reputeAlexa Stott has a reputation beyond reputeAlexa Stott has a reputation beyond reputeAlexa Stott has a reputation beyond reputeAlexa Stott has a reputation beyond reputeAlexa Stott has a reputation beyond reputeAlexa Stott has a reputation beyond repute
Send a message via AIM to Alexa Stott
Re: button control

For each port on your OI, you have px_sw_top, px_sw_trig, px_sw_aux1, and px_sw_aux2 with "x" being the appropriate port number. Each of these corresponds with a button or a trigger on whatever joystick is plugged into the port (trig and top being the most obvious).

Your code should look something like this when you program the buttons:
Code:
if(button)
{
     doSomething();
}
...and so on from there.

Remember that buttons are digital devices; they are either on or off (1 or 0, respectively).

To control time, we've always simply defined a static unsigned int to 0 and incremented it for each loop of the processor. It takes a lot of playing around to get the values right. There are other ways to do this, as stated above, but that is one of your options.

Hopefully that helps.
__________________
|Email:alexastott[at]gmail.com|Facebook|@zelixir|Google+|
[University of Maryland Computer Science, Psychology]
[Brunswick Eruption]

Last edited by Alexa Stott : 06-02-2008 at 21:32.
Closed Thread


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
XBOX button fondyfire12 Programming 8 25-05-2007 15:39
button programming joesmomh00haha Programming 12 10-02-2007 10:36
Sarcasm Button Jessica Boucher CD Forum Support 3 19-03-2006 16:02
Button Making PureMachine4 Rumor Mill 58 16-04-2004 16:00
Button Bar Adrian Wong CD Forum Support 8 04-06-2001 20:27


All times are GMT -5. The time now is 01:11.

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