3

I'm in the process of trying to create a "Aurora Glow" effect using a Particle Photon and a Neopixel ring.

I have the code fully working using a single Breadboard-friendly NeoPixel however when upgrading this to a NeoPixel Ring (16 LED) the code does not run as expected

The current working code for a single NeoPixel can be found here: http://pastebin.com/Yj1cywpx

It was my assumption that i could change Line 33 from one LED to Sixteen e.g.:

FastLED.addLeds<NEOPIXEL, 6>(&led, 1);

to

FastLED.addLeds<NEOPIXEL, 6>(&led, 16);

However when I run this code rather than all NeoPixels cycling through the Aurora Colours, only the very Top LED does and rest are either off or a static colour (e.g. https://i.stack.imgur.com/6rY38.jpg)

Could someone please advise what i missing? Apologies if this is a "Noob" question but this is my 2nd Arduino project and I cannot understand why this would not work.

Thanks

2 Answers 2

1

Never used neoPixels in arduino before so this is a complete guess based on reading the code but it looks like you are only setting the colour of the first LED.

Try creating 16 LED colours:

CRGB led[16];

and then setting them all:

for (int i = 0;i<15; i++) {
  int colourIndex = index + i;
  if (colourIndex > 15)
    colourIndex -= 15;
  led[i] = ColorFromPalette(auroraPalette, colourIndex , 255, LINEARBLEND);
}

edit - as @rDg indicates in his answer

FastLED.addLeds<NEOPIXEL, 6>(&led, 16);

becomes

FastLED.addLeds<NEOPIXEL, 6>(led, 16);

since led is now an array not a single value

Finally I think paletteSize should only be 16 not 5*16, you only have 16 colours in there.

3
  • Thanks Andrew for a swift response i will make the changes and let you know! Thanks again
    – 4dogsofwar
    Sep 27, 2016 at 13:18
  • Hi Andrew, When editing the void loop() to use the for loop i get: ringtest.cpp:41:6: error: 'i' was not declared in this scope do i need to declare this at the top of the script? pastebin.com/8FaDdzLW Thankyou again for your help
    – 4dogsofwar
    Sep 28, 2016 at 8:30
  • You need to declare it somewhere for (int i=0;... would work fine. I'll update the original answer...
    – Andrew
    Sep 28, 2016 at 9:08
0

In addition to the above, you need to tweak your addLeds line:

FastLED.addLeds<NEOPIXEL, 6>(led, 16);
4
  • That's confusing. I'm not sure why stackexchange is currently ordering your answer first. But, if I may, I think it would be clearer to say "In addition to @Andrew's answer, you need to tweak your addLeds line". Yes, I agree, it is no longer a variable but an array and no longer needs the ampersand.
    – st2000
    Sep 28, 2016 at 6:54
  • @rDg Thankyou for your comment i have since removed the ampersand. Taking yours and Andrews comments into account i have modified my script. Changing the if statemnet to use Andrews For loop. Getting errors compiling but working on the issues: pastebin.com/8FaDdzLW Thanks for your help
    – 4dogsofwar
    Sep 28, 2016 at 8:33
  • @4dogsofwar You seem to have removed most of the code from your loop() code. The for loop in my changes only replaced the single line that was setting the value of led, with code that set all 16 values. You still needed the other lines that were in your loop(). Something like this pastebin.com/5N1dEYTv
    – Andrew
    Sep 28, 2016 at 15:38
  • @Andrew. Apologies this was my mistake i wasnt 100% sure. I have edited the code (pastebin.com/nGgUXw9B) and it complies successfully :D I Will test and run the code when I'm home. I would like to thank you for bearing with me and your hard work, its been a very good learning exercise!
    – 4dogsofwar
    Sep 28, 2016 at 15:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.