Any idea why this code isn’t working?
Other examples work using the same setup.
Thanks
Phil
#include “FastLED.h”
#define DATAPIN 11
#define CLOCKPIN 13
#define NUMPIXELS 100
CRGB leds[NUMPIXELS];
void setup() {
Serial.begin(9600);
FastLED.addLeds<APA102, DATAPIN, CLOCKPIN, RGB>(leds, NUMPIXELS);
FastLED.setBrightness(255);
}// setup
void loop() {
for (int i = 1; i <= 10 ; i++) { // loop through first 10 pixles
leds[i] = CRGB(255, 0, 0);
FastLED.show();
FastLED.delay(1000 / 30);
} // for loop
}// loop
Hi
The first pixel is 0, not 1.
Also you never turn any pixel off, or dim any pixels so this code looks as though it’ll just set pixels 1 to 10 red. Then they’ll stay red.
Is this the behaviour you’re seeing?
marmil
(Marc Miller)
November 17, 2017, 7:23am
3
@Phil_Spitler What’s not working?
As Jeremy mentioned, you’re not darkening or clearing the pixel data anywhere so once it’s filled pixel 1 thru 10 red the first time through the main loop, nothing will change after that.
I would expect the first 10 LEDs to be Red but actually no LEDs turn on.
Actually, it was a power issue. When I used external power instead of USB it worked
marmil
(Marc Miller)
November 17, 2017, 7:40am
6
Yes, 100 pixels is probably too much to try to power by USB.
I was actually only illuminating the first 10 but it was still too much
marmil
(Marc Miller)
November 17, 2017, 7:49am
8
Note that even pixels that are off still use a tiny bit of power. It all adds up.
Actually the power they use when off is actually not that tiny, it adds up even more quickly.