1. 구성도
2. 코드
import RPi.GPIO as GPIO
import time
class display1:
def on():
f = open("/sys/class/backlight/10-0045/bl_power",'r')
file = f.read()
f.close()
list = file.splitlines()
print(list)
for line in list:
print(line)
if line == '1':
g = open("/sys/class/backlight/10-0045/bl_power", 'r')
new = g.write("0")
g.close()
def off():
f = open("/sys/class/backlight/10-0045/bl_power", 'r')
file = f.read()
f.close()
list = file.splitlines()
print(list)
for line in list:
print(line)
if line == '0':
g = open("/sys/class/backlight/10-0045/bl_power", 'w+')
new = g.write("1")
g.close()
sensor = 17
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(sensor, GPIO.IN)
try:
while True:
if GPIO.input(sensor) == 1:
print("on")
display1.on()
#time.sleep(0.5)
elif GPIO.input(sensor) == 0:
print("off")
display1.off()
time.sleep(0.5)
except KeyboardInterrupt:
GPIO.cleanup()
'Project > PTSD_Project' 카테고리의 다른 글
PTSD시연 영상 / PPT (0) | 2022.07.15 |
---|---|
[Raspberry Pi] GPS모듈(EZ-0048) 위도/경도 데이터 가공/전송 (0) | 2022.07.15 |
테이블 명세서 (0) | 2022.07.11 |
요구사항정의서 (0) | 2022.07.11 |