Oops. Sorry I think it should be
Code:
int handstate;
handstate = 0; //default position for whatever your using
if (p1_sw_trig == 1 && handstate == 0)
{
relay2_fwd = 1;
handstate = 1;
}
else if (p1_sw_trig == 1 && handstate == 1)
{
relay2_rev = 1;
handstate = 0;
}
Though I think your code would work too.