Thread: toggle switch
View Single Post
  #23   Spotlight this post!  
Unread 25-01-2006, 19:15
Windward's Avatar
Windward Windward is offline
Registered User
FRC #1452
Team Role: Programmer
 
Join Date: Nov 2005
Rookie Year: 2004
Location: So Cal
Posts: 88
Windward is an unknown quantity at this point
Re: toggle switch

I am trying to get the code to work with 2 spikes. It works with 1 spike, but I'm still a little confused on how to modify.

Code:
if(initVar != 1)
{
	relay2_fwd != relay2_rev;
	initVar = 1;
}

if (p1_sw_trig && !oldstate)
{
	relay1_fwd = !relay1_rev;
	relay1_rev = !relay1_fwd;
	relay2_fwd = !relay2_rev;
	relay2_rev = !relay2_fwd;
}
if (p1_sw_trig != oldstate)
	oldstate = p1_sw_trig;
I initialized the relay2 fwd & rev so it was opposite. Otherwise the code was pretty much the same.

I am not sure where to procede from here.