Python Daily
2.57K subscribers
1.48K photos
53 videos
2 files
38.9K links
Daily Python News
Question, Tips and Tricks, Best Practices on Python Programming Language
Find more reddit channels over at @r_channels
Download Telegram
Screen/monitor controlled by PIR sensor

I have three files, all in the same directory (/home/pi/pir)

1. [pir.py](https://pir.py)\--> Main code to detect PIR sensor from GPIO

2. [scON.sh](https://scON.sh) \--> Shell to turn ON screen via dpms

3. [scOFF.sh](https://scOFF.sh) \--> Shell to turn OFF screen via <xset dpms force off> (works from terminal)

&#x200B;

My objective is to toggle the monitor on and off depending on the state of the PIR sensor. The time.sleep times are just in there for testing purposes - I still have to figure that part out.

High = turn on

Low = turn off

&#x200B;

Here is my main code in the [pir.py](https://pir.py) file. I inserted the error I get (when I trip the PIR) as comment lines within the code, but I am new to python, Linux, etc and do not understand the errors.

Here is the main code to sense PIR and toggle screen on (when HIGH) and off (when LOW). could someone kindly point me in the right direction to get this working?

&#x200B;

import RPi.GPIO as GPIO #Import GPIO library
import time #Import time library
import subprocess

GPIO.setmode(GPIO.BOARD) #Set GPIO pin numbering


/r/Python
https://redd.it/cyphtc