View Single Post
  #8   Spotlight this post!  
Unread 04-03-2011, 22:43
Mr. Lim Mr. Lim is offline
Registered User
AKA: Mr. Lim
no team
Team Role: Leadership
 
Join Date: Jan 2004
Rookie Year: 1998
Location: Toronto, Ontario
Posts: 1,125
Mr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond repute
Re: WPI Lib Relay class - individual line control

Code:
int redLight = 0;
int whiteLight = 0;

void updateLights()
{
	int combinedLights;

	combinedLights = (redLight << 1) + whiteLight;

	switch (combinedLights)
	{
		case 0:
			myRelay.set(Relay.Value.kOff); // M+ and M- = 0V (Both Off)
		break;

		case 1:
			myRelay.set(Relay.Value.kForward); // M+ = 12V, M- = 0V (White Only)
		break;

		case 2:
			myRelay.set(Relay.Value.kReverse); // M+ = 0V, M- = 12V (Red Only)
		break;

		case 3:
			myRelay.set(Relay.Value.kOn); // M+ = 12V, M- = 12V (Both On)
		break;
	}

}
Something like the above will give you two independent variables representing the lights that you can change without knowing the state of the other light. Just call updateLights periodically.
__________________
In life, what you give, you keep. What you fail to give, you lose forever...
Reply With Quote