Help with GPIO trigger - Raspberry Pi Forums
hi all,
first new boards , new messing around raspberry pi, running mine digital taplist beer fridge using raspberry pints, have added pir motion sensor wake screen when motion detected. working great wanted integrate additional function trigger ssr turn on fridge lights when same motion detected, have ssr wired gpio24 (pin18 & pin20 ground) , having hard time manipulating code ssr switch when motion dectected.
, appreciated, below current code running screen wake.
pic of beer fridge.
first new boards , new messing around raspberry pi, running mine digital taplist beer fridge using raspberry pints, have added pir motion sensor wake screen when motion detected. working great wanted integrate additional function trigger ssr turn on fridge lights when same motion detected, have ssr wired gpio24 (pin18 & pin20 ground) , having hard time manipulating code ssr switch when motion dectected.
, appreciated, below current code running screen wake.
code: select all
#!/usr/bin/env python import os import rpi.gpio gpio import time cmd = 'xscreensaver-command -deactivate' gpio.setmode(gpio.bcm) pir_pin=7 gpio.setup(pir_pin, gpio.in) def motion(pir_pin): os.system(cmd) time.sleep(1) time.sleep(2) try: gpio.add_event_detect(pir_pin, gpio.rising, callback=motion) while 1: time.sleep(100) except keyboardinterrupt: gpio.cleanup()
what have tried , and how didn't work? might try along lines of:
code: select all
gpio.setmode(gpio.bcm) pir_pin = 7 ssr_pin = 18 gpio.setup(pir_pin, gpio.in) gpio.setup(ssr_pin, gpio.out) def motion(pir_pin): os.system(cmd) gpio.output(ssr_pin, 1) time.sleep(1) gpio.output(ssr_pin, 0)
raspberrypi
Comments
Post a Comment