Quote:
|
Originally Posted by Mike
Remember KISS.
Code:
char activated = 0;
if(switch == 1) // If we told it to change states
{
if(activated == 0)
{
relay1_fwd = 1;
relay1_rev = 0;
activated = 1;
}
else
{
relay1_fwd = 0;
relay1_rev = 1;
activated = 0;
}
}
Voila.
|
Not quite.. that code requires a very fast trigger finger..
Basically:
Code:
char oldstate;
if (p1_sw_top && !oldstate) {
relay1_fwd = !relay1_fwd;
relay1_rev = !relay1_rev;
}
if (p1_sw_top != oldstate) oldstate = p1_sw_top;
Should work. It requires you to release the button and press it again to re-activate the change.