Created
April 28, 2018 06:10
-
-
Save powerwlsl/3ac469868735bcda836e82e37f8e282d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import RPi.GPIO as GPIO | |
import time | |
import os | |
GPIO.setmode(GPIO.BCM) | |
GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP) | |
while True: | |
input_state = GPIO.input(18) | |
if input_state ==False: | |
if open('tmp').readline().rstrip() == "0": | |
os.system("sudo bash -c 'echo 1 > /sys/class/backlight/rpi_backlight/bl_power'") | |
os.system("echo 1 > tmp") | |
else: | |
os.system("sudo bash -c 'echo 0 > /sys/class/backlight/rpi_backlight/bl_power'") | |
os.system("echo 0 > tmp") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment