class Relay
The relay object controls the state of the relays. The relays are bistable making them remember their state when power is removed.
Constructor
- class omc048.relay(id: integer)
Create an relay object associated with the relay 1 or 2.
id
is the relay number, 1 or 2.
Methods
- relay.set(state: integer)
Set the relay to the specified position, 1 for on and 0 for off.
- relay.on()
Switch the relay to the on position (normally open). Connecting pin 11-12 for relay 1 and pin 17-18 for relay 2.
- relay.off()
Switch the relay to the off position (normally closed). Connecting pin 12-13 for relay 1 and pin 18-19 for relay 2.
- relay.toggle()
Switch the relay from the current position to the other position, switching between on() and off().
Example
The following code shows an example with the relay switching between positions with a 5 second interval.
import omc048
import time
relay_1 = omc048.relay(1)
while True:
relay_1.toggle()
time.sleep(5)