Quote:
Originally Posted by Joe Ross
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...