3,15 → 3,18 |
import time |
import subprocess |
|
power_sense_pin = 83 |
|
gpio.wiringPiSetupGpio() |
gpio.pinMode(88, 0) |
gpio.pullUpDnControl(88, 0) |
gpio.pinMode(power_sense_pin, 0) |
gpio.pullUpDnControl(power_sense_pin, 0) |
|
time.sleep(2) |
|
oldstav = gpio.digitalRead(88) |
oldstav = gpio.digitalRead(power_sense_pin) |
|
while True: |
stav = gpio.digitalRead(88) |
stav = gpio.digitalRead(power_sense_pin) |
|
if oldstav == 0 and stav == 0: |
subprocess.call("shutdown -P 0", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |