달력

07

« 2018/07 »

  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  •  
  •  
  •  
  •  

'PIR'에 해당되는 글 1

  1. 2017.03.27 라즈베리파이3 - 모션센서 PIR

라즈베리파이3 - 모션센서 PIR


cat motion.pir.02.py 

import RPi.GPIO as GPIO

import time

 

GPIO.setmode(GPIO.BCM)

PIR_PIN = 25 # GPIO PIN POSITION

GPIO.setup(PIR_PIN, GPIO.IN)

 

def MOTION(PIR_PIN):

    print "Motion Detected!"

 

print "PIR Module Test(CTRL+C to exit)"

time.sleep(2)

print "Ready"

 

try:

    GPIO.add_event_detect(PIR_PIN, GPIO.RISING, callback=MOTION)

    while 1:

        time.sleep(100)

 

except KeyboardInterrupt:

    print "Quit"

    GPIO.cleanup()


Posted by 멋지다마라송


티스토리 툴바