Pages: [1]   Go Down
Author Topic: when x and d == some value....do this one time.  (Read 314 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

When my robot is centered(variable x) to the object, and when my distance is equaled to some amount(variable d). I would like it to drop my arm() function, do it once but redo if variables change. I can add my code but it's a bit long. If anyone wants to look at it, I willing to post it.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 551
Posts: 46266
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
When my robot is centered(variable x) to the object, and when my distance is equaled to some amount(variable d). I would like it to drop my arm() function, do it once but redo if variables change.
Are you asking for permission or help? If you want permission, go ahead.

If you need help, you need to define what you need help with. Calling the function when x is equal to some value and d is equal to some value is easy:
Code:
if(x == SomeValue && d == SomeOtherValue)
{
   arm();
}

To ensure that arm() only gets called once:

Code:
bool armDone = false;

void loop()
{
   // Some stuff

   if(x == SomeValue && d == SomeOtherValue && !armDone)
{
   arm();
   ardMode = true;
}

At some point in the code, you will need to set armDone back to false, or else the arm will never move again.
Logged

Pages: [1]   Go Up
Jump to: