Mar-24-2025, 08:49 AM
Hello,
I know very little about Python programming, so be gentle with me please
I have a script for detecting a PIR movement on a Raspberry Pi 3b.
I would be grateful if anyone can tell me how to run these commands from within a Python script
Thanks in advance
I know very little about Python programming, so be gentle with me please
I have a script for detecting a PIR movement on a Raspberry Pi 3b.
from gpiozero import MotionSensor
import os
import RPi.GPIO as GPIO
import time
pir = MotionSensor(21)
while True:
pir.wait_for_motion()
print("You moved")
pir.wait_for_no_motion()I want to turn a monitor on with the command 'DISPLAY=:0.0 xrandr --output HDMI-1 --auto --rotate left' if movement is detected and off with the command 'DISPLAY=:0.0 xrandr --output HDMI-1 --off' after, say, 5 minutes.I would be grateful if anyone can tell me how to run these commands from within a Python script
Thanks in advance
