Hi all!!! I'm working on a project with Fire2012.

Hi all!!!

I’m working on a project with Fire2012. I have 2 pots, 1 controls the brightness, which works fine. The other 1 I would like to use to control the NUM_LEDS, to make it shorter or taller.
The problem I’m running in to is is in the first part of the Fire2012() function:
static byte heat[NUM _ LEDS];

In my case it’s:
static byte heat[siveVal];

“sizeVal” being the value being read from the pot.

The compiler complaint is:
“storage size ‘heat’ isn’t constant”

I’ve tried several different ways to make it work, with no joy. Is there another way to declare the “heat” variable, or what should I do???

Thank you for your help!!!

Arduino Nano with WS2812B’s

Try keeping NUM_LEDs for all the array definitions like leds[] and heat[], but then change NUM_LEDS to sizeVal in the for()-loops. (that is, those arrays contain the maximum number of LEDs)

Actually, I think you may want to keep NUM_LEDs in the Step 1 for()-loop too, so that if you turn the knob down, the higher LEDs will fade down.

@Tod_Kurt Agreed, NUM_LEDs is the size of the Array. And you want to manipulate the the “maximum index” into the array.

@Tod_Kurt @Jimmy_Edwards Thanks for the response.
It sort of works, but if I switch to that function and “sizeVal” is greater than 14, it locks up the Nano and resets it.
I’ve spent quite a bit of time on it and can’t seem to figure it out.

The lines in question are 101-131
Any idea’s???

Thank you!

You’re doing “NUM_LEDS+5” in your map() but your array is “heat[NUM_LEDS]”. So then later you’re trying to address beyond the end of the heat[] array. Try taking off off that “+5”.

@Tod_Kurt that makes sense. I think I have a bad pot. The highest that the serial print will read is 17 when I have 22 LEDs.
You think it would work if I added a + 5 to all the NUM_LEDS?

I would investigate what’s up with your pot. Make a new sketch with just an analogRead() and Serial.println() and see what it’s outputting. Maybe the pot’s bad or wired up oddly and you can use that sketch to diagnose that. And then use the max value from the test sketch to replace the “1023” in your map().

But just from the ratios, it sounds like you’re driving the pot from 3V on a 5V system.

@Tod_Kurt I figured it out about 2 minutes ago.
It’s a power problem. All the while before I was just running it off USB power and getting the bad pot readings. When I got home a little while ago I had it hooked up to a wall wart and USB. The pot was working just fine. I unplugged the wall wart and started getting bad readings again.
This is the first time I’ve used a Nano, so I don’t know if that has something to do with it or not. I just never had that problem with an Uno or a Mega.
Now we know…

Thank you so much for your help!!!