View Single Post
  #12   Spotlight this post!  
Unread 13-02-2014, 18:54
Domenic Rodriguez's Avatar
Domenic Rodriguez Domenic Rodriguez is offline
Registered User
FRC #0316 (LuNaTeCs)
Team Role: College Student
 
Join Date: Sep 2010
Rookie Year: 2011
Location: Grove City, PA
Posts: 213
Domenic Rodriguez has a spectacular aura aboutDomenic Rodriguez has a spectacular aura aboutDomenic Rodriguez has a spectacular aura about
Re: Programming Ring Light [Java]

Quote:
Originally Posted by Joe Ross View Post
This will not do what you expect. kOn sets both outputs of the spike to 12v, which will cause a motor or an LED to be off. You should use kForward.

You can use kOn if you set the direction of the relay to Forward only.
I guess I was assuming that kOn would be equivalent to kForward by default; thanks for the heads up. So adding a call to Relay#setDirection() would give the desired behavior, right?
Code:
// Create the relay
Relay ledRelay = new Relay(RELAY_PORT);

// Specify the direction for the relay
ledRelay.setDirection(Relay.Direction.kForward);

// Control the relay
ledRelay.set(Relay.Value.kOn);
ledRelay.set(Relay.Value.kOff);
Normally I would just use kForward. The reasoning here was to avoid accidentally setting the relay to kReverse and potentially damaging the LEDs. Granted, it's easy enough to just remember not to use kReverse...
__________________

LuNaTeCs - Learning Under Nurturing Adults Teaching Engineering Concepts and Skills - Small and Mighty!

FRC 316 LuNaTeCs - Student (2011-2014), Lead Programmer (2011-2014), Team Captain (2013-2014), Operator (2013), Drive Coach (2014), Mentor (2015-????)
'11 Philly Regional Finalists, '13 Chestnut Hill Finalists, '13 Lenape Champions, '13 Archimedes Division, '14 Chestnut Hill Champions, '14 Lenape Champions
FTC 7071 EngiNerds - Founding Advisor (2013-2014) | FRC 5420 Velocity - Founding Advisor (2015)
Grove City College Class of '18, Electrical/Computer Engineering (B.S.E.E)

Reply With Quote