scottlawsonbc / audio-reactive-led-strip

:musical_note: :rainbow: Real-time LED strip music visualization using Python and the ESP8266 or Raspberry Pi
MIT License
2.68k stars 644 forks source link

Blue LEDs not lighting up, other colors fine #281

Closed Nawor3565 closed 4 years ago

Nawor3565 commented 4 years ago

I'll preface this by mentioning that I'm using a H801 module with an ESP8266 and "dumb" LED strip.

After setting it up, everything seems to function properly, but the blue LEDs simply don't light up as often/bright as they should. It's sort of hard to describe, so I took a video here. As you can see, the blue LEDs almost don't light up at all, but when I close Visualization.py and the H801 goes into standby mode, you can see that the blue LEDs are fine. Meaning, it's definitely not a hardware issue.

That means the problem lies somewhere in either the Arduino firmware from issue #256 or the Python visualizer itself. I tried messing with the RGB value calculations in the firmware, visualization.py and LED.py, but I wasn't able to change much. I could probably figure more out if I had a proper addressable LED strip to tinker with, but alas, I'm stuck with my LEDs from 2014.

Please let me know if there's any more info I can give that would help troubleshoot, or if you need more examples of the problem. Thanks!

joeybab3 commented 4 years ago

Can you post your Arduino code? If you're having 2/3 colors working it's probably something simple that just isn't obvious

Nawor3565 commented 4 years ago

Here's what I'm using, it was written by gaijinsr in issue #256. I'm 99% sure that you're right, because I just tried using the ledFX program which was built using this repo and the blue LEDs don't work at all with it, even though again, green and red work fine.

gaijinsr commented 4 years ago

The blue LEDs light up when the strip runs the idle rainbow cycle, so the connection to the H801 seems to be OK. Since the blue LEDs correspond to the high frequencies (IIRC), I would guess that your input is not the original music but what your microphone picks up and that therefore the high frequencies are missing. Is the blue curve as high as the red and green curves in the visualisation window?

Nawor3565 commented 4 years ago

Yep, all the curves are roughly equal. It also happens when using the "static color" option in ledFX.

I spent a few hours messing with it last night, and I found out that the colors in visualizer.py and ledFX are in the wrong order, so the red LEDs light up when the green ones should, and the green ones light when the blue ones should, etc. So the problem is actually with the red LEDs. I can just swap the wires so it doesn't matter, but it sure made troubleshooting more confusing.

Also, manually changing the "r" value at the end of the Arduino sketch to 1023 will make the red LEDs turn on max brighness, so it appears that the issue lies within the Arduino code that processes incoming UDP packets. Unfortunately, I'm not able to get any serial console output from the ESP8266, so I can't figure out what the actual RGB values it's getting are. I'm also just bad at network stuff in general so looking at the UDP code in LED.py is like hieroglyphics to me.

Nawor3565 commented 4 years ago

I fixed it! You know when you spend hours trying to do in-depth debugging, only for the solution to be really simple? This is one of those times. On line 110 of the Arduino code, it had:

red=data[0]; green=data[1]; blue=data[2];

On a whim, I changed it to:

red=data[1]; green=data[2]; blue=data[3];

And now everything works fine. I'm not sure why the red LEDs would sometimes still light up, but it probably has to do with the setup treating the whole strip like a single LED. Regardless, it works now, so this can be closed.

gaijinsr commented 4 years ago

Now your red LEDs show the green value of the first pixel, the green LEDs show the blue value of the first pixel and your blue LEDs show the red value of the second pixel. If the blue value of your data stream is always 0 (as seems to be the case), 0,1,2->3,4,5 would be a better choice because it would keep the colours correct.

Nawor3565 commented 4 years ago

That's odd, it seems to be working fine on my end. When I test it using the "static color" effect in ledFX, the LEDs do light with the correct colors. I also confirmed it maps correctly by disabling two of the colors at a time in visualization.py (for example, output = np.array([0*r, g, 0*b]) * 255 to test green).