205Views7Replies

Author Options:

Arduino controlled NeoPixel 300 LED strip, code only works if I specify 295 LEDs? Answered

I am controlling a 5m (60 LEDs/m) NeoPixel RGBW LED strip with an Arduino Uno.  When using the NeoPixel library you specify the number of LEDs connected to the Arduino.  On another LED strip (1m @ 144LEDs/m) specifying more LEDs than are on the strip will just send data to the imaginary LEDs and the rest of the strip will still work.  On the 5m strip it will only work if I specify 295 or less; specifying more than 295 makes the whole strip freeze.  Only specifying 295 leaves 5 LEDs at the end that don't light up at all.

Any ideas why that might be?

Discussions

None
Downunder35m

Best Answer 2 years ago

I don't know exactly how the library works but I do know each pixel needs 3 bytes of ram to work.
Depending on how it works you might just be out of memory...

None
DeanRogersDownunder35m

Answer 2 years ago

Oh, okay. Is there a way I can use the flash memory instead of RAM in this scenario? I know it's possible to assign constants to flash...

None
icengDeanRogers

Answer 2 years ago

You can create a logic algorithm that uses very little memory and does the color scheme you want by computing the next 16 LEDs set them and do the next 16 differently depending on your abilities...

None
Downunder35mDeanRogers

Answer 2 years ago

Unless you really need to assign each pixel you simply put some strips in parallel on the same Arduino pin.
Most effects don't really use a single LED but a sequence instead.
295 is a very odd number but 2 X 147 or the standard 144 would work...
Bur it depends on what you are actually trying to do here...

None
steveastroukDeanRogers

Answer 2 years ago

Well work out how much RAM you're using, it sounds like you are 15 bytes short. If you can push the constants into Flash, will it save 15 bytes.

None
DeanRogers

2 years ago

Thanks for all the tips, I was able to clean up my code free up enough memory without using flash memory.