I have many pins on my raspberry pi GPIO constantly set to high, and I can't seem to set them to low, even after GPIO.cleanup(). Is my Pi faulty? Some seem to be set to low, and I can't set them to high. I seem to only be able to get 17, 18, 14 and 15 the voltages and the grounds to function normally.

code that works

    # importing the GPIO library 
    import RPi.GPIO as GPIO
    # importing the time library for time functions.
     time import sleep

    # Set the pin mode to Broadcom SOC.
    # Turn off warnings.
    # Set the GPIO pins for the stepper motor:

    StepPins = [17,18,14,15]
    #StepPins = StepPins.reverse()

    # Set all pins as output.
    for pin in StepPins:
      print("Setup pins")
      GPIO.output(pin, False)

    # Define variables.
    StepCounter = 0

    # Define simple order
    StepCount1 = 4
    Seq1 = []
    #Seq1 = range(0, StepCount1)
    Seq1 = [0,1,2,3]
    Seq1[0] = [1,0,0,0]
    Seq1[1] = [0,1,0,0]
    Seq1[2] = [0,0,1,0]
    Seq1[3] = [0,0,0,1]

    # Which order of steps are we going to use?
    Seq = Seq1
    StepCount = StepCount1

      while True:
        print("new loop")
    #    for pin in range(0,4):
        for pin in [0,1,2,3]:
  xpin = StepPins[pin]
  if Seq[StepCounter][pin]!=0:
    #        print("Step: {} GPIO Active:".format(StepCounter,xpin))
    GPIO.output(xpin, True)
    print("%s pin high"%xpin)
    GPIO.output(xpin, False)
    print("%s pin low"%xpin)

StepCounter += 1

# When we arrive at the end of the sequence, start again
if StepCounter == StepCount:
  StepCounter = 0
if StepCounter<0:
  StepCounter = StepCount

#  Wait for the next step (lower = faster rotation speed)

    except KeyboardInterrupt:
    # Close GPIO neatly

but if I change one of the pins (and the corresponding wiring, and get someone else to check it after I've checked it several times), to 24, 23 or 22 it doesn't work. It's like I can't control these specific pins.

  • 1
    Without knowing your code and connections we can not help.
    – joan
    Feb 11 '18 at 16:49
  • 1
    Have you been setting pull-up or pull-down resisters in the Pi? Are you absolutely sure that you are using the right pin numbers? There are two sets of pin numbers (logical and Broadcom pin numbers).
    – NomadMaker
    Feb 11 '18 at 17:39
  • Also, are you checking the state of the pin when connected to a circuit? The pins should be connected to either ground or +3V3. If you just leave them hanging, they may still be indeterminate.
    – NomadMaker
    Feb 11 '18 at 17:42
  • Hi everyone, thanks for your responses. I added code to the original post, and I checked every wire with a voltmeter as well as checking positions several times and getting someone else to cross check.
    – Grace
    Feb 11 '18 at 18:00
  • So you have connected pins 11, 12, 8, and 10?
    – joan
    Feb 11 '18 at 18:55

Do check the hardware mode in which you are using your RPI. Perhaps your hardware mode and your python aren't matching, leading to this strange behaviour by Raspberry Pi.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.