well, if you're trying to turn a motor/solenoid/whatever else on/off only, without variable speed, i would use a spike. the code is simple.
Code:
static char trigold = 0; // Define this with global scope
if(p1_sw_trig == 1 && trigold == 0){
relay1_fwd = !relay1_fwd;
}
trigold = p1_sw_trig;
That should toggle relay1's fwd direction each time there is a 0->1 transition on the port 1 trigger.