I hope someone can help me with this. I have tried ‘six ways to Sunday’ trying to get this to work like I want but I am stuck… I am trying to take a small piece of code written by Andrew Tulane and put it in a subroutine instead of the main loop where it is now.
Here is a link to the original code:
I want to be able to call this from the main loop.
I use Arduino IDE 1.8.2 and FastLED 3.1
I can get it compile but when loaded in chip it crashes the chip.
I always try to figure out my problems without bothering anyone else, but I just cant seem to make this run. I am stuck!. Any help would be appriciated. (my programming skills are ‘less than par’.)
Put your code up in a gist for folks to look at - that way, it’ll be easier to make suggestions on what might need to be changed.
OMG, a big ugly picture of me. The horror!
Here is link to my code. https://github.com/Jack149/BlendProject
There is a menu system in it. I am using a ‘Select case’ statement to choose patterns. I know the menu coding is a bit nuts, but here is how it works. Press B (mode), press patternNumer, press ‘#" to engage the program. Press’*’ to clear the program. The menu part works fine, and the code WILL compile, but crashes the chip when pattern starts.
first of all - you only need to include FastLED.h - i don’t know why all the other header files are getting pulled in there, but you don’t want that.
the second one of these should be NUM_LEDS-1:
fill_gradient_RGB(leds, 0, endclr, NUM_LEDS/2, midclr);
fill_gradient_RGB(leds, NUM_LEDS/2+1, midclr, NUM_LEDS-1, endclr);
(why? because that end position is an actual item in the array - but if an array has 32 elements in it, then the index of the last item is 31. attempting to access array[32] is out of bounds, and writes random locations which tends to make chips unhappy.
Aaahh. I see. Thank you! I put the ‘-1’ in like you suggested and it lit up right away!. WOOHOO! … I learn something every day!