Thread: button Switch
View Single Post
  #1   Spotlight this post!  
Unread 07-02-2009, 12:01
aaeamdar's Avatar
aaeamdar aaeamdar is offline
Post-A-Holic
AKA: Paul Dennis
FRC #1719 (The Umbrella Corp)
Team Role: College Student
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Baltimore, MD
Posts: 231
aaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant future
Re: button Switch

This is actually a really simple issue for programming. The exact implementation depends on your programming environment. Here is how you would do it in C/C++:

Code:
bool motorIsRunning = false
...
if (theButton == PRESSED)
{
    motorIsRunning = !motorIsRunning;
}

...

if (motorIsRunning)
{
    motorValue = FULL_FWD;
}
else
{
    motorValue = STOP;
}
The one thing that this code will do that is different than what you are looking for (perhaps) is that if you hold down the button, it will continue to flip the motor flag. Of course, this is easy to fix, if you think about it.

Good luck,
Paul