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.
GPIO.setmode(GPIO.BCM)
# Turn off warnings.
GPIO.setwarnings(False)
# 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.setup(pin,GPIO.OUT)
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
try:
while True:
print("new loop")
# for pin in range(0,4):
for pin in [0,1,2,3]:
xpin = StepPins[pin]
print(xpin)
if Seq[StepCounter][pin]!=0:
# print("Step: {} GPIO Active:".format(StepCounter,xpin))
GPIO.output(xpin, True)
print("%s pin high"%xpin)
else:
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)
sleep(0.01)
except KeyboardInterrupt:
# Close GPIO neatly
GPIO.cleanup()
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.