Skip to Main Content

Dorper Okay, Now THIS Is Epic

On/Off control of motors and other mechanisms - Relays

For On/Off control of motors or other mechanisms such as solenoids, lights or other custom circuits, WPILib has built in support for relay outputs designed to interface to the Spike H-Bridge Relay from VEX Robotics. These devices utilize a 3-pin output (GND, forward, reverse) to independently control the state of two relays connected in an H-Bridge configuration. This allows the relay to provide power to the outputs in either polarity or turn both outputs on at the same time.

Relay connection overview

The roboRIO provides the connections necessary to wire IFI spikes via the relay outputs. The breakout board provides a total of eight outputs, four forward and four reverse. The forward output signal is sent over the pin farthest from the edge of the board, labeled as FWD on the silkscreen, while the reverse signal output is sent over the center pin, labeled REV. The final pin is a ground connection.

Relay Directions in WPILib

Within WPILib relays can be set to kBothDirections (reversible motor or two direction solenoid), kForwardOnly (uses only the forward pin), or kReverseOnly (uses only the reverse pin). If a value is not input for direction, it defaults to kBothDirections . This determines which methods in the Relay class can be used with a particular instance.

Setting Relay Directions

exampleRelay = new Relay(1);
exampleRelay = new Relay(1, Relay.Value.kForward);


Relay state is set using the set() method. The method takes as a parameter an enumeration with the following values: