简体   繁体   English

运行Python脚本会导致Raspberry Pi断电

[英]Running Python script causes Raspberry Pi to lose power

I've created the following script: 我创建了以下脚本:

import RPi.GPIO as GPIO
import time
GPIO.setwarnings(False)
GPIO.cleanup()
GPIO.setmode(GPIO.BCM)
GPIO.setup(15,GPIO.OUT)
GPIO.output(15,False)
GPIO.setup(6,GPIO.IN,pull_up_down=GPIO.PUD_DOWN)
while GPIO.input(22) == GPIO.LOW:
    time.sleep(0.1)
    if GPIO.input(6)==GPIO.HIGH:
            print("YAY")

The purpose of this code is to detect the press of a button connected to my Raspberry Pi, but even without any circuitry set up, just starting this script causes the pi to lose power. 此代码的目的是检测是否按下了连接到我的Raspberry Pi的按钮,但是即使没有设置任何电路,仅启动此脚本也会导致pi掉电。 Does anyone have any ideas why this may be and how to fix it? 有谁知道为什么会这样以及如何解决呢?

I tried your script. 我试过你的剧本。 It locks up the rpi at this line 它在这一行锁定了rpi

GPIO.setup(6,GPIO.IN,pull_up_down=GPIO.PUD_DOWN)

GPIO06 isn't one of the pins on the GPIO port. GPIO06不是GPIO端口上的引脚之一。 You'd have look at the schematic to see what it's connected to. 您将查看原理图以查看其连接的内容。 Looks like it's LAN_RUN. 看起来是LAN_RUN。 What are you trying to do with it? 您打算如何处理?

From elinux.org 来自elinux.org

GPIO06 is LAN_RUN and is available on pad 12 of the footprint for IC3 on the Model A. On Model B, it is in use for the Ethernet function. GPIO06是LAN_RUN,可在型号A的IC3的占位面积的焊盘12上使用。在型号B上,它用于以太网功能。

So unless you have a model A, you shouldn't be using GPIO06 因此,除非您拥有模型A,否则不应使用GPIO06

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM