Go to Post 254 bends CIM shafts every now and then in the drivetrain. I didn't believe it was possible until I saw it myself. - AustinSchuh [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #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
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 11:12.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi