Alright, I finally figured it out! Here is how I did it.
Code:
if (p1_sw_trig && rel1==0)
{
rel1++;
if (rel2==0)
{
relay1_fwd=1;
rel2++;
}
else
{
relay1_rev=1;
rel2--;
}
}
if (!p1_sw_trig)
{
rel1=0;
relay1_fwd=0;
relay1_rev=0;
}
rel1 and rel2 are simply declared as ints, where rel1 is initialized to 0, and rel2 to 1. This makes it go forward at first, then backwards the next time.