Do something like this:
Code:
unsigned char state = 0;
unsinged char switchState = 0;
// Check switches. Substitute switch for whatever switch on the OI you are using
// I use the switch state to prevent the switching of the state do to not realeasing the button right away
if(switch && !switchState)
{
// Set switch state
swtichState = 1;
// Switch states
if(switch)
state = 0;
else
state = 1;
}
else if(!switch)
{
// reset the switch state
switchState = 0;
}
// Subitute relay with your relay
if(state)
{
// Run forward
relay_fwd = 1;
relay_rev = 0;
}
else
{
// Turn off relay
relay_fwd = 0;
relay_rev = 0;
}
Put that whole thing where ever you are doing your cheking currently. Put the varable declarations at the top of whatever function you have this in. That should work. (I hope...

)