forked from andreknieriem/photobooth
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbutton.py
43 lines (37 loc) · 1013 Bytes
/
button.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
#!/usr/bin/env python3
#
# Licensed under MIT license. See full license in LICENSE file.
#
# Author: Jarett Rude
from gpiozero import LED, Button, DigitalOutputDevice
from time import sleep
from signal import pause
from subprocess import check_call
import uinput
# SHUTDOWN BUTTON
def shutdown():
check_call(['sudo', 'poweroff'])
shutdown_btn = Button(21)
# DEFINE TIGGER BUTTON WITH LED
triggerLED = LED(18)
triggerButton = Button(4)
# DEFINE SIGNAL TO ARDUINO FOR LIGHTS
arduinoTrigger = DigitalOutputDevice(13,active_high=True,initial_value=False)
def send():
arduinoTrigger.on()
#print(arduinoTrigger.value)
sleep(2)
arduinoTrigger.off()
while True:
triggerLED.on()
if triggerButton.is_pressed:
#print("pressed")
with uinput.Device([uinput.KEY_ENTER]) as device:
sleep(1)
device.emit_combo([uinput.KEY_ENTER])
send()
sleep(8)
if shutdown_btn.is_pressed:
#print("shutdown")
shutdown()
pause()