Go to Post Indeed, the more ways you fail, the more ways you know something doesn't work.:) - Steven Sigley [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 Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #5   Spotlight this post!  
Unread 09-05-2011, 17:17
TofuRama TofuRama is offline
01000110 01010010 01000011
AKA: Matt
FRC #2484 (Team Implosion)
Team Role: Programmer
 
Join Date: Apr 2011
Rookie Year: 2009
Location: Woods Cross Utah
Posts: 17
TofuRama is an unknown quantity at this point
Re: Wait(); function

I looked at your code and there are a few issues with it. One is that the timer will never get past 1. This is because it sets it to 0 within the if statement but also increments it only in the if statement as well. Another issue is that you're only checking to see if the motors should stop in the if statement. You can try this code and see if it should work:

//declare the timer as static to keep the value from the last loop
static int timer = 0;

//check if the trigger was pushed
if(Thirdstick.GetTrigger())
{
//if so, start the motors and reset the timer
timer = 0;
motor->Set(1.0);
}
//increment the timer
timer++;
if(timer >= 1000)
{
//stop the motors
motor->Set(0.0);
}

Also, as for an actual timer there is a timer class. Below is the syntax to use it:

//create a new timer class
Timer *timer = new Timer();
//start the timer
timer->Start();
//reset the timer, call this anytime that you want the timer to be set at zero
timer->Reset();

I hope this helps!
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


All times are GMT -5. The time now is 14:55.

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