Looking for support with Addressable LEDs

I have recently taken up the endeavor of attempting to add addressable LEDs to my V5 robot. I attempted to use multiple different solutions including: sylib, jpearman’s addressable LED demo, and attempted to do it in vexcode text with python (as it is supposed to have rudimentary LED support). The python appeared to be the most promising, however when it ran the function to set them all to a specific color, it appeared to pass over it. The only time the LED’s would do anything was when first turning on the brain (it would just light up random colors). I was hoping to be able to receive some support on this.

This was the code I was attempting to use:

class AdvancedAddressableLed(AddressableLed):
    pass

    def all_red(self):
        self.set([Color(0x800000)] * 64)

    def all_green(self):
        self.set([Color(0x008000)] * 64)

    def all_blue(self):
        self.set([Color(0x000080)] * 64)

    def rotate(self, data):
        data[:] = data[1:] + data[:1]
        self.set(data)

a=AdvancedAddressableLed(brain.three_wire_port.b)

brain.screen.print("test") #to see when it is about to start the function
def test1():
    a.all_red()
    brain.screen.print("Done") #just to make sure it ran the function
test1()```
(I had attempted to create the original class, but it already existed so i presumed it had that as base functionality)

Did the jpearman addrled demo work? It’s possible the specific three-wire port is broken, so try multiple. If the addrled demo is not working, most likely there is a problem with the compatibility of the strip.

Add some exception handling around the initialization to see if your a object is properly initialized:

try:
    brain.screen.print("Starting LED initialization...")
    a = AdvancedAddressableLed(brain.three_wire_port.b)
    brain.screen.print("LED initialized successfully")
except ValueError as ve:
    brain.screen.print(f"ValueError: {ve}")
    brain.screen.print(f"Port type: {type(brain.three_wire_port.b)}")  # Debugging the port type
except TypeError as te:
    brain.screen.print(f"TypeError: {te}")
    brain.screen.print(f"Port type: {type(brain.three_wire_port.b)}")  # Debugging the port type
except Exception as e:
    brain.screen.print(f"Unexpected error: {e}")
    brain.screen.print(f"Port type: {type(brain.three_wire_port.b)}")  # Debugging the port type

If this doesn’t give you any useful debig information, you can try some simplified code like this:

try:
    led = AddressableLed(brain.three_wire_port.b)
    led.set([Color(0x800000)] * 10)  # Set all LEDs to red
    brain.screen.print("Simple LED test passed")
except Exception as e:
    brain.screen.print(f"Simple test failed: {e}")

If that doesn’t help, you can try using a different port or do some hardware checks:

  • Ensure the data, power, and ground wires are connected correctly.
  • Confirm common ground Ensure the LED strip and VEX brain share a ground.
  • Make sure the LEDs are getting enough power. If the LEDs require 5V but the brain outputs 3.3V, this may cause an issue if no additional power source is being used
  • Confirm the LED type and protocol are supported by the VEX library.

But the most important thing is, this should be the last thing you worry about. Your robot should be perfect at this time for you to spend energy on LEDs :grinning:

probably hardware compatibility issue if the code is good.

3 Likes

Thanks for the response, I’ll hopefully be able to test this tomorrow, and I’ll get back if it works. If not can always try different LED’s, or just get non addressable in the color I want “”_('’ )/“”.

Sorry for the heavily delayed response, did like you said and focused on my robot before working on this.
I used the code you suggested (had to modify it slightly because the f strings kept giving me errors when using the brain print function). It said it successfully initialized and that it passed the test, however the LED’s did not work.
So it is most likely a hardware issue, hopefully I will be able to find a set of the LED’s that are compatible. Thanks for the help :smiley:

Finally solved the issue :partying_face:, it was a combination of both a hardware issue, as well as my own stupidity. To solve the hardware issue I dropped the voltage using a diode before raising it back up to 5v, (shoutout mavric). The code issue was something incredibly simple, I had forgotten to properly add a 3 wire when I created that test project. The demo code provided by Lucian worked perfectly with the diode added as well as the 3 wire properly initialized. Thank you guys for the help, looking forward to this next season (especially with my LEDs)