-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathButton_Light.py
More file actions
43 lines (43 loc) · 875 Bytes
/
Button_Light.py
File metadata and controls
43 lines (43 loc) · 875 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
40
41
42
43
import RPi.GPIO as GPIO
import time
import sys
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.OUT)
GPIO.setup(23, GPIO.OUT)
GPIO.setup(24, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(25, GPIO.OUT)
thing = True
def inputCheck(times):
for n in range(times):
if(GPIO.input(24) == False):
break
else:
time.sleep(1.0/times)
try:
while True:
switchValue = GPIO.input(24)
time.sleep(0.1)
if(switchValue == True):
GPIO.output(18, True)
inputCheck(20)
GPIO.output(18, False)
GPIO.output(23, True)
inputCheck(20)
GPIO.output(23, False)
GPIO.output(25, True)
inputCheck(20)
GPIO.output(25, False)
thing = True
count = 0
else:
print("hi")
if(thing == False and count >20):
GPIO.cleanup()
sys.exit()
elif(thing == False):
count += 1
else:
thing = False
count = 1
except KeyboardInterrupt:
GPIO.cleanup()