avidan
March 22, 2017, 9:57pm
1
I’m using the neopixel library on this strip: https://www.amazon.com/gp/product/B01533H3CG/ref=oh_aui_search_detailpage?ie=UTF8&psc=1
I’m using an external supply, but no matter the code I write, the pixels don’t light up with the correct lights.
#include "Particle.h"
#include "neopixel.h"
SYSTEM_MODE(AUTOMATIC);
#define PIXEL_PIN D2
#define PIXEL_COUNT 2
#define PIXEL_TYPE WS2812B
Adafruit_NeoPixel strip(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
void setup()
{
strip.begin();
strip.show(); // Initialize all pixels to 'off'
}
void loop()
{
strip.setPixelColor(0, 255, 0, 0);
strip.setPixelColor(1, 255, 0, 0);
}
You need to call strip.show()
after you’re done with updating the LEDs
setPixelColor()
only wirtes the data to the array where the color info for the strip is held, but show()
actually transfers the data from the array to the strip.
avidan
March 22, 2017, 10:04pm
3
Now those 2 pixels are flashing, but random colors…
avidan
March 22, 2017, 10:05pm
4
ok. needed to put the commands in setup (or i guess i could have put a wait() ) in the loop
1 Like
You may need to slow down the update rate.
Since you are only setting the LEDs once, you could just do this
void setup()
{
strip.begin();
strip.setPixelColor(0, 255, 0, 0);
strip.setPixelColor(1, 255, 0, 0);
strip.show(); // Initialize all pixels to 'off'
}
void loop()
{
}
or add a delay(100)
at the end of your loop()
Obviously you came to the same conclusions while I was typing this