First of all, sorry for my bad English.
I am using an ESP32 with a WS2812B LED strip
BTF-LIGHTING 16.4ft 5m WS2812b 30leds/pixels/m individually addressable connected to a
Switching Power Supply 5V 10A 50W DC Power Adapter AC 100V/240V to DC-5V.
I am using Arduino Ide to program it but there is no way for it to work, I have done all kinds of tests, with a few LEDS with all the LEDs, but it sets the color it wants and turns them on when it wants.
The code I use is the following:
#include <Adafruit_NeoPixel.h>
#define LED_PIN 5 // Digital pin connected to the LED strip
#define LED_COUNT 4 // Number of LEDs in the strip
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin();
strip.setPixelColor(0, strip.Color(255, 255, 255));
strip.setPixelColor(1, strip.Color(255, 255, 255));
strip.setPixelColor(2, strip.Color(255, 255, 255));
strip.setPixelColor(3, strip.Color(255, 255, 255));
}
void loop() {
strip.show();
}
In this example it turns the first LED green and the rest blink white.
This is the first example I used, and I simplified until I reached the previous code.
In this one, some LEDs illuminated in red and others in green, but most of them did not work.
#include <Adafruit_NeoPixel.h>
#define PIN_WS2812B 16 // The ESP32 pin GPIO16 connected to WS2812B
#define NUM_PIXELS 30 // The number of LEDs (pixels) on WS2812B LED strip
Adafruit_NeoPixel ws2812b(NUM_PIXELS, PIN_WS2812B, NEO_GRB + NEO_KHZ800);
void setup() {
ws2812b.begin(); // initialize WS2812B strip object (REQUIRED)
}
void loop() {
ws2812b.clear(); // set all pixel colors to ‘off’. It only takes effect if pixels.show() is called
// turn pixels to green one-by-one with delay between each pixel
for (int pixel = 0; pixel < NUM_PIXELS; pixel++) { // for each pixel
ws2812b.setPixelColor(pixel, ws2812b.Color(0, 255, 0)); // it only takes effect if pixels.show() is called
ws2812b.show(); // update to the WS2812B Led Strip
delay(500); // 500ms pause between each pixel
}
// turn off all pixels for two seconds
ws2812b.clear();
ws2812b.show(); // update to the WS2812B Led Strip
delay(2000); // 2 seconds off time
// turn on all pixels to red at the same time for two seconds
for (int pixel = 0; pixel < NUM_PIXELS; pixel++) { // for each pixel
ws2812b.setPixelColor(pixel, ws2812b.Color(255, 0, 0)); // it only takes effect if pixels.show() is called
}
ws2812b.show(); // update to the WS2812B Led Strip
delay(1000); // 1 second on time
// turn off all pixels for one seconds
ws2812b.clear();
ws2812b.show(); // update to the WS2812B Led Strip
delay(1000); // 1 second off time
}
Hi.
I’m sorry, but without further info, it’s very difficult to find out what might be wrong…
If you’re using an ESP32, maybe you need to use a level-shifter to transform the 3.3V signal into a 5V signal that is compatible with the strip. Search for “rgb led strip level shifter”.
I’ve used this one previously with a Raspberry Pi, and it worked well: https://makeradvisor.com/tools/logic-level-converter-module/
But, I’m not sure if that’s your issue… it’s difficult to tell.
Regards,
Sara
I am using a power supply, you can see it in the first question, on the ESP32 I only have the control PIN connected to pin 5, the code above is the one I used to do the first test.,
I am using an ESP32 with a WS2812B LED strip
BTF-LIGHTING 16.4ft 5m WS2812b 30leds/pixels/m individually addressable connected to a
Switching Power Supply 5V 10A 50W DC Power Adapter AC 100V/240V to DC-5V.
I am using Arduino Ide to program it but there is no way for it to work, I have done all kinds of tests, with a few LEDS with all the LEDs, but it sets the color it wants and turns them on when it wants.
The code I use is the following:
#include <Adafruit_NeoPixel.h>
#define LED_PIN 5 // Digital pin connected to the LED strip
#define LED_COUNT 4 // Number of LEDs in the strip
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin();
strip.setPixelColor(0, strip.Color(255, 255, 255));
strip.setPixelColor(1, strip.Color(255, 255, 255));
strip.setPixelColor(2, strip.Color(255, 255, 255));
strip.setPixelColor(3, strip.Color(255, 255, 255));
}
void loop() {
strip.show();
}
In this example it turns the first LED green and the rest blink white.
The first code I used is this:
#include <Adafruit_NeoPixel.h>
#define PIN_WS2812B 16 // The ESP32 pin GPIO16 connected to WS2812B
#define NUM_PIXELS 30 // The number of LEDs (pixels) on WS2812B LED strip
Adafruit_NeoPixel ws2812b(NUM_PIXELS, PIN_WS2812B, NEO_GRB + NEO_KHZ800);
void setup() {
ws2812b.begin(); // initialize WS2812B strip object (REQUIRED)
}
void loop() {
ws2812b.clear(); // set all pixel colors to ‘off’. It only takes effect if pixels.show() is called
// turn pixels to green one-by-one with delay between each pixel
for (int pixel = 0; pixel < NUM_PIXELS; pixel++) { // for each pixel
ws2812b.setPixelColor(pixel, ws2812b.Color(0, 255, 0)); // it only takes effect if pixels.show() is called
ws2812b.show(); // update to the WS2812B Led Strip
delay(500); // 500ms pause between each pixel
}
// turn off all pixels for two seconds
ws2812b.clear();
ws2812b.show(); // update to the WS2812B Led Strip
delay(2000); // 2 seconds off time
// turn on all pixels to red at the same time for two seconds
for (int pixel = 0; pixel < NUM_PIXELS; pixel++) { // for each pixel
ws2812b.setPixelColor(pixel, ws2812b.Color(255, 0, 0)); // it only takes effect if pixels.show() is called
}
ws2812b.show(); // update to the WS2812B Led Strip
delay(1000); // 1 second on time
// turn off all pixels for one seconds
ws2812b.clear();
ws2812b.show(); // update to the WS2812B Led Strip
delay(1000); // 1 second off time
}
Hi.
I was not referring to the power source.
I’m referring to the signal used to control the strip.
Even though you’re powering the strip with 5V, the signal from the ESP32 is a 3V3 signal. The level-shifter will transform a 3V3 signal into a 5V signal.
You can also try using a different ESP32 GPIO pin.
Regards,
Sara