1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | import time import RPi.GPIO as io io.setmode(io.BCM) pir_pin = 18 door_pin = 23 io.setup(pir_pin, io.IN) # activate input io.setup(door_pin, io.IN, pull_up_down=io.PUD_UP) # activate input with PullUp while True: if io.input(pir_pin): print("PIR ALARM!") if io.input(door_pin): print("DOOR ALARM!") time.sleep(0.5) |
1 | nano switches.py |
1 | sudo python switches.py |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |