-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
51 lines (42 loc) · 902 Bytes
/
main.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
#!/usr/bin/python
import RPi.GPIO as GPIO
import time, sys
from gpiozero import LED
from time import sleep
import vlc
led = LED(27)
led2 = LED(17)
readysound = vlc.MediaPlayer("/home/pi/projects/bahnuebergang/ding.wav")
# Use Pin Numbers, not GPIO numbers
# GPIO.setmode(GPIO.BOARD)
GPIO.setup(9, GPIO.IN)
def switch_on(pin):
global led, led2
p = vlc.MediaPlayer("/home/pi/projects/bahnuebergang/barriere.wav")
p.play()
print("go")
i = 0
while i < 13:
led.on()
led2.off()
sleep(1)
led2.on()
led.off()
sleep(1)
i = i+1
led2.off()
return
GPIO.add_event_detect(9, GPIO.FALLING, bouncetime=34*1000)
GPIO.add_event_callback(9, switch_on)
readysound.play()
led.on()
led2.on()
sleep(1.5)
led.off()
led2.off()
try:
while True:
time.sleep(5)
except KeyboardInterrupt:
GPIO.cleanup()
sys.exit()