- class wpilib.Relay(channel, direction=None)¶
Controls VEX Robotics Spike style relay outputs.
Relays are intended to be connected to Spikes or similar relays. The relay channels controls a pair of pins that are either both off, one on, the other on, or both on. This translates into two Spike outputs at 0v, one at 12v and one at 0v, one at 0v and the other at 12v, or two Spike outputs at 12V. This allows off, full forward, or full reverse control of motors without variable speed. It also allows the two channels (forward and reverse) to be used independently for something that does not care about voltage polarity (like a solenoid).
Relay constructor given a channel.
Initially the relay is set to both lines at 0v.
- channel (int) – The channel number for this relay (0-3)
- direction (Relay.Direction) – The direction that the Relay object will control. If not specified, defaults to allowing both directions.
- class Direction¶
The Direction(s) that a relay is configured to operate in.
- kBoth = 0¶
Both directions are valid
- kForward = 1¶
Only forward is valid
- kReverse = 2¶
Only reverse is valid
- class Relay.Value¶
The state to drive a Relay to.
- kForward = 2¶
- kOff = 0¶
- kOn = 1¶
On for relays with defined direction
- kReverse = 3¶
Get the Relay State
Gets the current state of the relay.
When set to kForwardOnly or kReverseOnly, value is returned as kOn/kOff not kForward/kReverse (per the recommendation in Set)
Returns: The current state of the relay Return type: Relay.Value
- Relay.relayChannels = <wpilib.resource.Resource object at 0x7f1f5ee33c18>¶
Set the relay state.
Valid values depend on which directions of the relay are controlled by the object.
When set to kBothDirections, the relay can be set to any of the four states: 0v-0v, 12v-0v, 0v-12v, 12v-12v
When set to kForwardOnly or kReverseOnly, you can specify the constant for the direction or you can simply specify kOff and kOn. Using only kOff and kOn is recommended.
Parameters: value (Relay.Value) – The state to set the relay.