I recently got the APA102 and started with my first tries with feastLed and I’m having some weird issues.
I wrote a program to control a single LEDs position, hue and saturation with three potentiometers. It worked for a few seconds without a problem but then the poti for saturation also controlled the position of the led.
It ended up with a full white LED on one side end when I turn the poti to the other end, I had the set color on the other side of the strip.
I can’t really find out what the cause for this is.
I hooked everything up directly to my arduino uno. power isn’t an issue because it is only one LED that is on.
Code is here: http://pastebin.com/Vtf3nwu1
I’m really glad for any help.
Try changing these:
uint8_t hue = 0;
uint8_t saturation = 0;
To these:
int hue = 0;
int saturation = 0;
Thanks for your answer, but that wasn’t the issue.
I figured it out: The array with the leds goes from 0 to 59, but the mapped value went from 0 to 60. I changed the line
mapLeds = map(poti1val, 0, 1023, 0, NUM_LEDS);
to
mapLeds = map(poti1val, 0, 1023, 0, NUM_LEDS - 1);
And now it seems to work
Aah, the old ‘NUM_LEDS - 1’ issue.
Sometimes makes me want to reserve NUM_LEDS+1 in the initial setup.
Yeah, I tried to work with the stuff from the “Basic Usage” Page from the wiki and there wasn’t anything like this mentioned. I’m glad, that it works now.
@Andrew_Tuline Bravo. Thank you for this information. @Mark_Kriegsman @Daniel_Garcia Would you consider adding something like this into the main information area of this page? Or perhaps this link? Now, when people look for help, or general programming/troubleshooting questions, we can say “you tried everything Andrew Tuline recommends, and still nothing works?” 