Raspi 3 PIR sensor - Python script - invalid syntaxPython

Python-Programme
Anonymous
 Raspi 3 PIR sensor - Python script - invalid syntax

Post by Anonymous »

Ich arbeite an einem "Magic Mirror" und jetzt habe ich ein Problem mit dem Python -Skript, das meinen Monitor einschalten sollte.

Code: Select all

#!/usr/bin/env python

import sys
import time
import RPi.GPIO as io
import subprocess

io.setmode(io.BCM)
SHUTOFF_DELAY = 60  # seconds
PIR_PIN = 7         # Pin 26 on the board

def main():
io.setup(PIR_PIN, io.IN)
turned_off = False
last_motion_time = time.time()

while True:
if io.input(PIR_PIN):
last_motion_time = time.time()
sys.stdout.flush()
if turned_off:
turned_off = False
turn_on()
else:
if not turned_off and time.time() > (last_motion_time + SHUTOFF_DELAY):
turned_off = True
turn_off()
time.sleep(.1)

def turn_on():
subprocess.call("sh /home/pi/Documents/PIR/monitor_on.sh", shell=True)

def turn_off():
subprocess.call("sh /home/pi/Documents/PIR/monitor_off.sh", shell=True)

if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
io.cleanup()
Ich habe versucht, das Skript auszuführen, aber Python sagt mir, dass es in Zeile 25 einen Syntaxfehler gibt, und es zeigt genau auf das Semikolon nach & amp und vor gt

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post