I'm working on my vu meter.

I’m working on my vu meter. But I have a bug I can’t figure it out. Sometimes my arduino hangs and reboot. Very anoying because the animation stops for 3 seconds.
This is my current code: http://pastebin.com/Uhp0Prc6

I have make in the setup serial print STARTING and in my Serial Monitor I sometimes see STARTING. For example I see:
height = 67
height = 67
height = 67
height = 67
height = žSTARTING

But the height is then heigher as the maximum leds in my strip? Is this maybe why the arduino hangs and reboots?

Hi @Dwain_Scheeren ​​ odd reboots and hangs are either power related (too many leds lit too brightly) or code related. E.g You have 60 leds but some poor math means you write into leds[80].

You need some bounds checking on ‘height’

Thank you @Stuart_Taylor I can do in the for loop a check if height is lower then max_leds stop doing writing. Then it will be fixed I guess. Going to test tonight. Suit needs to be ready in 2 days haha.

Now I only want to make that the audi detect code, part without for loop for fill leds runs automatic. So I can make multiple voids with different animations where I can use height in. Anyone thought on that? Place that code in the loop with every_n_milieseconds(20) and check the analog input and make messurements?

That would limit the seen framerate to 50 fps. I´d write in the loop something like:
-read data
-maybe soften (or average) the data
-render one frame of the choosen animation
So you measure basically before every single frame.