Controlling 5V led strip using MaxMSP and Arduino

I try to control a 5v led strip (3 pin: 5V,GND, Data) using maxMSP software.
Here is my arduino code:

#include <Adafruit_NeoPixel.h>

// Pin where your LED strip is connected
#define PIN1 6

// Set maximum number of LEDs you want to control
#define MAX_LEDS 25  // Change this to the actual number of LEDs in your strip
int numLeds = MAX_LEDS;  // Set this variable based on how many LEDs you want to use

// Create the NeoPixel strip object
Adafruit_NeoPixel strip1 = Adafruit_NeoPixel(MAX_LEDS, PIN1, NEO_GRB + NEO_KHZ800);

void setup() {
  // Initialize serial communication at 115200 baud
  Serial.begin(115200);

  // Initialize the LED strip
  strip1.begin();
  strip1.show();  // Initialize all pixels to 'off'
}

void loop() {
  // Check if there is data available in the serial buffer
  if (Serial.available() > 0) {
    int r = Serial.parseInt();  // Read red value
    int g = Serial.parseInt();  // Read green value
    int b = Serial.parseInt();  // Read blue value

    // If a complete set of values (r, g, b) is received, apply them to all LEDs
    if (Serial.read() == '\n') {
      // Loop through all the LEDs and set the color
      for (int i = 0; i < numLeds; i++) {
        strip1.setPixelColor(i, r, g, b);  // Set the color for each LED
      }
      strip1.show();  // Update the LED strip to reflect the changes
    }
  }
}

When I'm controlling les then 40~ leds it is working fine. The moment I try to controll more leds the last leds are changing colors not according to the color I choose via Max msp.
Why is that?
could it be because I'm powering the led strip from the Arduino 5V pin?

Here is a screenshot of my Max Patch:

OK so some update - it is working well when I pass from one color to another manually. If I'm using the RGB platte it stuck the code and color is not changing.
Anyway to solved that?

For an Uno / Mega / Leonardo you can (with a little luck you) power (8) 6 NeoPixels on full white from the 5V pin. This assumes that you're powering the Arduino over USB; powering on Vin or the barrel and it will be less.

You need roughly 60mA per NeoPixel for full white.

Post a simple schematic showing your power sources. If you are powering them from the Arduino forget it and go get a power supply that is large enough to power all of the pixels. Assume 1 Amp for each 16 pixels.


Which makes no mention of maxMSP. So can you run the Arduino code using regular serial input, and do the same problems occur?

This looks more like a problem with maxMSP than the simple Arduino sketch and circuit.

a7

So I have 5v 4A PSU and I’m powering the ledstrip with it instead directly from the arduino. I still have hard time to get constant color such as yellow, orange etc.

Is this because 4A is not enough to power all the 300 LEDs?

300 LEDs (on full white) requires 300x60mA. For that you need (with a little overhead included) a 20A power supply.

Every strip needs a 5V and GND connection to the power supply at roughly each 50..60 LEDs.

So I bought a 5V 20A PSU - I thought it will solved my problem with the light strip changing color across the strip but it desplay the light same as when I am using 5V 4A PSU.

So I guess I’m facing different issue.

What else can it be?

Make more use of the serial monitor to see if you are feeding plausible numbers to the LEDs.

Post the code you are using to test your strip.

Maybe write a find a simpler test sketch for the strip.

Try the code (any of the sketches) with quite a few LEDs.

Post a picture of your circuitry. Post a schematic showing how power gets to the things that need it.

a7