-
Notifications
You must be signed in to change notification settings - Fork 0
/
buzzer.py
116 lines (99 loc) · 2.21 KB
/
buzzer.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# Import the required module.
import RPi.GPIO as GPIO
#Setup the Pins For Input
GPIO.setmode(GPIO.BCM)
GPIO.setup(2, GPIO.IN)
GPIO.setup(3, GPIO.IN)
GPIO.setup(25, GPIO.IN)
GPIO.setup(11, GPIO.IN)
#Vars for Checking if there is a change
unoorange=0
dosorange=1
unopink=0
dospink=1
unoblau=0
dosblau=1
unogruen=0
dosgruen=1
while 1:
# Oranger Buzzer
if GPIO.input(2):
if unoorange==dosorange:
file = open("buzzer.txt", "r")
starttest = file.readline(5)
file.close()
if starttest =="start":
#Prints in the shell
print "Orange"
#using txt file as a cash for the color, later used by the info-beamer
file = open("buzzer.txt", "w")
file.write("Orange")
file.close()
unoorange=0
dosorange=1
else:
if unoorange!=dosorange:
if open("buzzer.txt", "r") !="Tot2":
print "tot1"
unoorange=dosorange
#Pinker Buzzer
if GPIO.input(3):
if unopink==dospink:
file = open("buzzer.txt", "r")
starttest = file.readline(5)
file.close()
if starttest =="start":
print "Pink"
file = open("buzzer.txt", "w")
file.write("Pink")
file.close()
unopink=0
dospink=1
else:
if unopink!=dospink:
print "Tot2"
unopink=dospink
#Blauer Buzzer
if GPIO.input(25):
if unoblau==dosblau:
file = open("buzzer.txt", "r")
starttest = file.readline(5)
file.close()
if starttest =="start":
print "Blau"
file = open("buzzer.txt", "w")
file.write("Blau")
file.close()
unoblau=0
dosblau=1
else:
if unoblau!=dosblau:
print "Tot3"
unoblau=dosblau
#Gruener Buzzer
if GPIO.input(11):
if unogruen==dosgruen:
file = open("buzzer.txt", "r")
starttest = file.readline(5)
file.close()
if starttest =="start":
print "Gruen"
file = open("buzzer.txt", "w")
file.write("Gruen")
file.close()
unogruen=0
dosgruen=1
else:
if unogruen!=dosgruen:
print "Tot4"
unogruen=dosgruen
#Neustart-Checker
file = open("buzzer.txt", "r")
starttest = file.readline(5)
file.close()
if starttest !="start":
reset=""
reset=raw_input("Neustart? - Return.")
file = open("buzzer.txt", "w")
file.write("start")
file.close()