GPIO控制,而真正的:

问题描述 投票:0回答:1

嗨,我得到所有的时间失败的原因:

photo_booth.py:18:RuntimeWarning:此通道已在使用中,继续反正。使用GPIO.setwarnings(false)来取消警告。 GPIO.setup(RELAI,GPIO.OUT)

我也试着控制与GPIO 18人继电器,但它是不工作的。我与一些人尝试过,但什么都没有改变。该继电器我所有的时间和它不能使用命令关闭。什么是我的问题吗?

你能告诉我这个问题?

#!/usr/bin/python

import RPi.GPIO as GPIO, time, os, subprocess, signal

# GPIO setup

GPIO.setmode(GPIO.BCM)

SWITCH = 24
GPIO.setup(SWITCH, GPIO.IN)
RESET = 25
GPIO.setup(RESET, GPIO.IN)
RELAI = 19
GPIO.setup(RELAI, GPIO.OUT)
GPIO.output(RELAI, GPIO.LOW)
j = 0
k = 0

def entprellen(schalter):
    entprellungs_puffer = 0
    schalter_puffer = 0
    for i in range(1, 11):
        entprellungs_puffer = entprellungs_puffer +1
        schalter_puffer = schalter_puffer + schalter
        time.sleep(0.05)
        if entprellungs_puffer == schalter_puffer:
            print("entprellt")
            return 1
        else:
            return 0

while True:
    if(GPIO.input(SWITCH)):
        j = entprellen(GPIO.input(SWITCH))

        if (j):
            GPIO.output(RELAI,GPIO.LOW)
            time.sleep(0.5)
            print("pose!")
            print("SNAP")
            gpout = subprocess.check_output("gphoto2 --capture-image-and-download --filename /home/pi/photobooth_images/photobooth%H%M%S.jpg", stderr=subprocess.STDOUT, shell=True)
            print(gpout)
            print("please wait while your photos print...")

            subprocess.call("sudo /home/pi/scripts/photobooth/assemble_and_print", shell=True)

            time.sleep(10)
            print("ready for next round")
            GPIO.output(RELAI,GPIO.HIGH)
GPIO.cleanup()
python raspberry-pi controls gpio
1个回答
0
投票

感谢@stevieb和@johnny MOPP是的,我明白了BCM OND BOARD模式差异性之探源。居然有人可以运行。问题是:我把它连接喜欢这里https://www.youtube.com/watch?v=TVR2SCMN8xY,但没有奏效。然后我试图改变形式的5至3.3V的PI和它的工作。问题是继电器切换不正确。我上冲许多方面非常不同势想着继电器。所以我不真的没有做什么。我现在bougth两个继电器:

这是第一个:https://www.amazon.de/gp/product/B01G1ENSTS/ref=ppx_yo_dt_b_asin_title_o03__o00_s00?ie=UTF8&psc=1

那几乎是相同的,但不同势品牌:https://www.amazon.de/gp/product/B00UFW1YNK/ref=ppx_yo_dt_b_asin_title_o01__o00_s00?ie=UTF8&psc=1我希望第二个是更好,因为它作为本教学中的相同。但没有改变。现在我买这一个:https://www.ebay.de/itm/252993630298它有一个销到线圈直接与5V电源和3.3是用于切换。

你认为它会工作,或者你有其他的想法????

谢谢您的帮助!

© www.soinside.com 2019 - 2024. All rights reserved.