I have a 144 LED strip - Adafruit NeoPixel Digital RGB LED Strip 144 LED, link here: https://www.adafruit.com/product/1507

If I create a simple project, eg turning pixels on off from the serial connection, then everything works fine. But when I build a solution with an ethernet jack and acting as a http server and lots more code, as soon as I try to show the strip then random pixels light up in random colours.

I know the code is logically ok because if I run it to eg print a string to the serial port, "Turning pixels 0-71 green" the code works.

There are 762 lines of code and quite a few global variables defined.

When I compile I see:

Sketch uses 19180 bytes (59%) of program storage space. Maximum is 32256 bytes.
Global variables use 1462 bytes (71%) of dynamic memory, leaving 586 bytes for local variables. Maximum is 2048 bytes.

I did previously see build messages warning of instability due to size of global variables which I cut down and at least don't see the instability warning now. Could it be that the code is using too many resources? Any tips of reducing the code and / or use of global variables?

I am powering via the USB cable. The unit is an Arduino Uno -the Arduino starter kit. Could it be a power issue?

I have a 470ohm resistor on the data line into pin 6. And a 1000uF capacitor between 5V+ and ground. Anything else that could help?

I am using the Neopixel library to control the led strip: https://github.com/adafruit/Adafruit_NeoPixel

  • Chances are the Neopixel library can't allocate the memory it needs (432 bytes) for the RGB buffer for the LEDs. I don't know what library you're using though. – Majenko Apr 7 '18 at 14:59
  • 1
    762 lines seems a lot for switching on a few lights. Are there any strings that you can move with the PROGMEM macro, (or whatever it’s called) – Code Gorilla Apr 8 '18 at 7:23
  • Maybe some interrupts are interfering with the data transmission to the strip and are destroying the timing of the pulses. The strips can be very sensitive. Maybe you can try to turn of interrupts for the execution oft strip.show(). – chrisl Apr 8 '18 at 14:05
  • @chrisl How would I turn the interrupts off? – Angus Comber Apr 8 '18 at 14:08
  • 1
    @chrisl by using F() for static strings and reducing the code size I am now able to light the pixels ok. I guess it must have been low static memory being the problem. But all the comments are useful if I see problems again. – Angus Comber Apr 8 '18 at 15:12

Your Answer

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

Browse other questions tagged or ask your own question.