-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswitch.py
More file actions
39 lines (26 loc) · 741 Bytes
/
switch.py
File metadata and controls
39 lines (26 loc) · 741 Bytes
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
#!/usr/bin/python3
import RPi.GPIO as GPIO
import time
logic_a = 16
logic_b = 18
GPIO.setmode(GPIO.BOARD)
GPIO.setup(logic_a, GPIO.OUT)
GPIO.setup(logic_b, GPIO.OUT)
try:
while(1):
GPIO.output(logic_a, GPIO.LOW)
GPIO.output(logic_b, GPIO.LOW)
time.sleep(1)
GPIO.output(logic_a, GPIO.LOW)
GPIO.output(logic_b, GPIO.HIGH)
time.sleep(1)
GPIO.output(logic_a, GPIO.HIGH)
GPIO.output(logic_b, GPIO.LOW)
time.sleep(1)
GPIO.output(logic_a, GPIO.HIGH)
GPIO.output(logic_b, GPIO.HIGH)
time.sleep(1)
except KeyboardInterrupt:
GPIO.output(logic_a, GPIO.LOW)
GPIO.output(logic_b, GPIO.LOW)
GPIO.cleanup()