Hello, I’m new to coding and even newer to Blynk. I’ve hit a snag on a sketch I’m working on. I’m trying to use a NodeMCU and Blynk/ZeRGBa to control a 300 LED WS2812B, but when I run the sketch, the strip doesn’t turn on. Associated information also doesn’t make it to my serial monitor.
I’m running a separate power supply for the strip, and the code is currently based off several examples I’ve found online. I know the strip (Pin D2), connections and power supply are fine, because when I upload the NeoPixel strandtest example, everything works. Additionally, I attached a test LED to pin D1 and added a Button Widget (V0) for it, but it’s the only part that works when I run my sketch. The only things in the Blynk project are the button for the test LED (V0) and ZeRGBA (V1, merge mode). I’ve included my code below. Any help would be IMMENSELY appreciated!
Never mind, I reloaded the sketch, and everything seems to be working now! I think I may need to find a way to step up my logic level from 3.3V to 5V though. It seems to stutter a bit with all the LEDs. Thank you for the assistance!
I have ZeRGBa set up for send on release, so no worries there. I think I resolved my stutter issues with a 100uF capacitor parallel with the +/- wires on the strip, but I’ll throw in the resistor too. Thanks for all the advice, and I’d still love to get some inspiration from your code if you find the time!
Please do yourself a favor and buy a proper level shifter (best bidirectional because they are commonly better quality).
I have a lot of experience with WS2812B LEDs and the hardware additions you made (cap but also a resistor is a good idea to reduce noise on boot etc.) were good.
But dont forget that these digitial LEDs are 5V logic, so 3.3V is on the low side for the HIGH threshold.
A level shifter will make it bullet proof
Another thing:
I would suggest to use the FastLED library.
Delete:
#include <SPI.h>
#include <Adafruit_NeoPixel.h>
and add:
#include <FastLED.h>
then replace your BLYNK_WRITE(V1) with this
BLYNK_WRITE(V1)
{
int R = param[0].asInt();
int G = param[1].asInt();
int B = param[2].asInt();
Serial.println(R);
Serial.println(G);
Serial.println(B);
for (int i = 0 ; i < Led_Count; i++ )
{
strip[i].setRGB(R, G, B);
}
LEDS.show();
}
Just realised I’ve changed my code over to use the NeoMatrix library instead of NeoPixel (although technically it still uses the NeoPixel library anyway).
I can post that code though if you would like?
Edit - I used FastLED library in the past (and it worked really well) but switched back to Neopixel/Neomatrix (because of my application, needed a grid type layout - hence the matrix )
Sure, I’d love the inspiration! Right now I’m struggling to figure out how to have conditional “modes” on my strip that I can choose from my Blynk Project.
In a nutshell it uses less ram, less flash, is visibly faster, better optimized math algorithms (faster) and possibilities for RGB<->HSV color transitions. (to name a few…)
Maybe not everything is needed for a simple blynk project, but as I have written android apps it really makes a huge difference.
A bit googleing would have given you more detailed answers: