-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelay_lib_seeed_test_1.py
44 lines (36 loc) · 1.13 KB
/
relay_lib_seeed_test_1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/python
'''*****************************************************************************************************************
Seeed Studio Relay Board Library V2
Test Application #1
By John M. Wargo (https://www.johnwargo.com)
********************************************************************************************************************'''
import sys
import time
from seeed_relay_v1 import Relay
def process_loop():
# turn all of the relays on
relay.all_on()
# wait a second
time.sleep(1)
# turn all of the relays off
relay.all_off()
# wait a second
time.sleep(1)
# now cycle each relay every second in an infinite loop
while True:
for i in range(1, 5):
relay.on(i)
time.sleep(1)
relay.off(i)
# Now see what we're supposed to do next
if __name__ == "__main__":
# Create the relay object
relay = Relay(action_output=True)
try:
process_loop()
except KeyboardInterrupt:
print("\nExiting application")
# turn off all of the relays
relay.all_off()
# exit the application
sys.exit(0)