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?
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.
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?
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.