Thread: toggle switch
View Single Post
  #2   Spotlight this post!  
Unread 16-01-2006, 15:28
Mike's Avatar
Mike Mike is offline
has common ground with Matt Krass
AKA: Mike Sorrenti
FRC #0237 (Sie-H2O-Bots (See-Hoe-Bots) [T.R.I.B.E.])
Team Role: Programmer
 
Join Date: Dec 2004
Rookie Year: 2004
Location: Watertown, CT
Posts: 1,003
Mike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond repute
Re: toggle switch

Remember KISS.
Code:
char activated = 0;

if(switch == 1) // If we told it to change states
{
	if(activated == 0)
	{
		relay1_fwd = 1;
		relay1_rev = 0;
		activated = 1;
	}
	else
	{
		relay1_fwd = 0;
		relay1_rev = 1;
		activated = 0;
	}
}
Voila.
__________________
http://www.mikesorrenti.com/