Skip to content

Instantly share code, notes, and snippets.

@skateman
Created January 23, 2022 11:56
Show Gist options
  • Save skateman/3d9b66ac845ccf0a9dfc99cb953d2d14 to your computer and use it in GitHub Desktop.
Save skateman/3d9b66ac845ccf0a9dfc99cb953d2d14 to your computer and use it in GitHub Desktop.
#!/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