Created
January 23, 2022 11:56
-
-
Save skateman/3d9b66ac845ccf0a9dfc99cb953d2d14 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import RPi.GPIO as GPIO | |
import time | |
from subprocess import call | |
GPIO.setwarnings(False) | |
GPIO.setmode(GPIO.BOARD) | |
GPIO.setup(11, GPIO.IN) | |
while True: | |
i = GPIO.input(11) | |
if i ==0: | |
print("Screen off", i) | |
call(["/usr/bin/vcgencmd", "display_power", "0"]) | |
time.sleep(1) | |
elif i ==1: | |
print("Screen on", i) | |
call(["/usr/bin/vcgencmd", "display_power", "1"]) | |
time.sleep(30) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment