简体   繁体   中英

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. 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

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

GPIO06 isn't one of the pins on the GPIO port. You'd have look at the schematic to see what it's connected to. Looks like it's LAN_RUN. What are you trying to do with it?

From 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.

So unless you have a model A, you shouldn't be using GPIO06

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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