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