negno
개발Log
negno
전체 방문자
오늘
어제
  • 분류 전체보기
    • Project
      • Mini_Project
      • PTSD_Project
    • Algorithm
      • Elice
      • JavaFestival
    • BACK-END
      • C Programming
      • JAVA
      • JSP Servlet
      • Python
      • Spring
      • Machine Learning
    • FRONT-END
      • HTML CSS
      • JavaScript
    • Application
      • Android
    • DataBase
      • Oracle
      • MySql
    • IoT
      • Arduino
      • Raspberry pi

티스토리

hELLO · Designed By 정상우.
negno

개발Log

[Raspberry Pi]인체감지센서(HC-SR501) Display ON/OFF
Project/PTSD_Project

[Raspberry Pi]인체감지센서(HC-SR501) Display ON/OFF

2022. 7. 11. 14:06

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
    negno
    negno

    티스토리툴바