1

I have the resistor, GPIO24, and the LED anode connected along the same row of a breadboard. The signal from GPIO24 works as expected, but any signal from GPIO23 is lost and the LED will not light. I don't know enough about circuits to debug this.enter image description here

This is the code I'm testing with, nothing happens for the first 6 seconds. It looks like nothing happens on GPIO23.

from gpiozero import LED


led23 = LED(23)
led24 = LED(24)

led23.blink(n=3, background=False)
led24.blink(n=3, background=False)

But for whatever reason this code works and lights the LED

from gpiozero import LED


led23 = LED(23)
led23.blink(n=3, background=False)
1
1

Since the Hi-Z option may not be available on RPi, perhaps try this alternate wiring arrangement:

schematic

simulate this circuit – Schematic created using CircuitLab

5
  • I tried your solution, but it didn't work as is. I was still getting the behavior where one led wouldn't light. Probably for the same reason in the answer I just posted. – Brady Dean Sep 17 '20 at 18:01
  • In the comments, you said, I'm only allowed to use 1 resistor. What happened to that requirement? – Seamus Sep 17 '20 at 19:30
  • Oh, I forgot to get back on that. It's ok to use more than 1. Instructions were written in such a way that we could use either a RPI or Arduino. I think the 1 resistor requirement had something to do with that idk – Brady Dean Sep 17 '20 at 19:37
  • I'm glad you got this working - good for you! For future reference however you should know that most GPIO pins can be placed in a high impedance state - in other words, the device may be "HI", "LO" or "Hi-Z", aka tri-state. I don't know gpiozero, but I do know how the hardware behaves. If what you've said about gpiozero is true, it seems this is a case of the tail wagging the dog! :) – Seamus Sep 17 '20 at 19:45
  • I've been reading through the gpiozero source and essentially it's just a wrapper around RPi.GPIO and all the LED class does is call RPi.GPIO.output on the pin. I can't tell why it's not working without running through a debugger – Brady Dean Sep 17 '20 at 20:06
1

I came to the conclusion there was nothing wrong with my circuit (and yes, I am now putting a 220 resistor on each led), but the problem was in software. Gpiozero doesn't work as expected when the same led is connected to 2 circuits. More specifically, I cannot have an LED object on pin 23 and 24 at the same time. My workaround is to switch out these LED objects during runtime.

from gpiozero import LED

led = LED(24)  # ref to whichever led being used

def switch_brightness():
    if led.pin.number == 24:
        led.close()
        led = LED(23)
    else:
        led.close()
        led = LED(24)

# use led, call switch_brightness when necessary

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.