I spent a significant part of today developing a sprite movement library for a 30-pixel NeoPixel strip using my Arduino Duemilanove (ATmega 168). It works like a charm. However, if I change N_LEDS to a significantly higher value, the program seems not to run. I can't get it to run on the Duemilanove for a strip of longer than 50.

In fact, (see the below code) a relatively high N_LEDS value won't even allow the test patterns to run as defined in setup(). This leads me to believe that inexplicably the constructor for Adafruit_Neopixel is failing.

A friend of mine (who has the ultimate application for this) is hoping to drive a strand of 750 LEDs using this code on an Arduino Due. I can't imagine memory would be an issue with the Due, so what's going on here?


#include <Adafruit_NeoPixel.h>

#define PIN    6
#define N_LEDS 30      // <-- If this number is > ~50, nothing happens
#define MAXSPRITES 5
#define SENSOR_TIMEOUT_IN_MS  2000
#define SCANNER_WIDTH  9

Strip declaration:

Adafruit_NeoPixel strip = Adafruit_NeoPixel(N_LEDS, PIN, NEO_GRB + NEO_KHZ800);

setup() and loop():

void setup() {



    manager = new SpriteManager();
    manager->Add(new TestPatternSprite(0, 0xff0000));
    manager->Add(new TestPatternSprite(5, 0x00ff00));
    manager->Add(new TestPatternSprite(10, 0x0000ff));

loop() {

Are there any coding mistakes in the above that wouldn't allow us to run this code on the Due? Or is this a known limitation?

  • Your question doesn't make it clear that you have tried the above code on a Due, and it failed. I thought you were saying that you tried it on a Duemilanove and it failed after a certain number of pixels. So you really have two problems? The number of pixels on the Duemilanove, and the fact that it doesn't light any (significant number of) pixels on the Due? Is that right? – Nick Gammon Jun 28 '15 at 21:49

Your Duemilanove only has 1k of RAM. That's not much. Each pixel takes 3 bytes of RAM (R/G/B). So (say) 60 pixels would be 180 bytes. That's less than 1k, but there would be other uses of RAM in your sketch.

750 LEDs sounds like pushing it for the low-RAM Arduinos.

You might want to look at NeoPixels Revealed: How to (not need to) generate precisely timed signals The author managed to drive over 1000 NeoPixels with a Duemilanove.

I'm not sure if that applies to your exact type of NeoPixels, but it is worth considering.

  • Ok, but upon reading my post, I think I wasn't entirely clear. Our desired configuration is on the Due -- we were only using the Duemilanove for testing. Any reason this wouldn't work on the Due? – James Cronen Jun 28 '15 at 17:30
  • The fact that it works up to some magic number would appear to indicate that RAM, and not something else, is the problem. So quite possibly it would work on the Due. Since the Due has 3.3V on its pins you would need to check this is adequate to drive the Neopixels, or maybe get a level shifter. Since the Due has 96k of RAM that may be enough to drive your intended number of pixels. There may possibly be some subtle issues in the library, regarding addressing that large an array, I couldn't say for sure. You would have to try it. :) – Nick Gammon Jun 28 '15 at 21:11
  • Thanks! But it doesn't. :-/ Perhaps the voltage is an issue; I believe the tests we had done on the strip only illuminated one pixel at a time. It's possible that maybe the voltage drop of lighting up multiple LEDs is enough to drop the voltage below some critical threshold for pixels. Still, I'd expect to see some kind of partial effect at least. Thanks for the help! – James Cronen Jun 28 '15 at 21:41
  • What is powering the Neopixels? Assuming they are running at 5V the 3.3V from the Due may be marginal in terms of being considered HIGH. I would try the level-shifter to see if that helps. – Nick Gammon Jun 28 '15 at 21:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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