View Single Post
  #21   Spotlight this post!  
Unread 08-02-2004, 02:55
Avarik Avarik is offline
Registered User
#0022
 
Join Date: Jan 2004
Location: Chatsworth, CA
Posts: 75
Avarik is an unknown quantity at this point
Re: A few questions on programming the Control System

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.