Go to Post Ya know...sometimes, design specs get changed at the last second. Or the market changes while you weren't watching. It Happens. - DonRotolo [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Spotlight this post!  
Unread 02-12-2009, 10:14 AM
sircedric4's Avatar
sircedric4 sircedric4 is offline
Registered User
AKA: Darren
no team (The SS Prometheus)
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2006
Location: Lousiana
Posts: 245
sircedric4 has a reputation beyond reputesircedric4 has a reputation beyond reputesircedric4 has a reputation beyond reputesircedric4 has a reputation beyond reputesircedric4 has a reputation beyond reputesircedric4 has a reputation beyond reputesircedric4 has a reputation beyond reputesircedric4 has a reputation beyond reputesircedric4 has a reputation beyond reputesircedric4 has a reputation beyond reputesircedric4 has a reputation beyond repute
Re: chaging values on an axis/toogle switch

Quote:
Originally Posted by Alex_2487 View Post
we are using the throttle axis on the joystick so it will work program the second way


right now my code for a motor is this

if (Thirdjoystick->GetRawButton (2)==1 )
{
frontroller->set(-1.0);
}
else if (Thirdjoystick->GetRawButton (3)==1 )
{
frontroller->set(1.0)
}
esle
{
frontroller->set(0.0)
}

right now the motor is off when we turn on the robot and when we hold down button 2 it rruns backwards and button 3 runs forward. i want to be able to make it so the second driver doesnt need to hold down the button and can just press it to switch between forward and stop and on the other button switch between backward and stop.

In this case you'll need to set a flag up. This will be in psuedocode but it will be something like:

You need to set a flag when the button is pressed, the problem is that the button is in an endless loop so you'll have to make sure you only poll the Buttonflag once each time the button is held down, so you'll need another flag for that.

Define a ButtonFirstflag
Define a Button2flag
Initialize the variables at the beginning:
Button2flag=false;
ButtonHeldflag = true;


if (Button2) {
if (ButtonFirstflag) {
if (!Button2flag) {
Button2flag = true;
} else {
Button2flag = false;
}
ButtonHeldflag = false;
}
ButtonHeldflag = true;

If (Button2flag) {
Motor = forward
} else {
Motor = stop
}

There maybe an easier means to do what you are asking, but this is what I use when I want to do what you are talking about. I hope I've helped.
Reply With Quote
 


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
Joystick values (?) beefy1 Programming 1 12-23-2008 11:26 AM
Joystick axis values in new controller koreabell Programming 7 12-17-2008 11:39 AM
penalties values??? colin340 Rules/Strategy 4 03-08-2008 09:37 PM
Need Help Wiring Micro Switch/Limiting Switch Windward Electrical 2 02-07-2006 06:26 PM
Servo Values DanDon Motors 8 02-14-2005 03:49 PM


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

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