Controlling 5v led strip from max to arduino
I have 5v led strip with 3 pin: 5V, Ground, Data pin.
I found this topic that was good start to control the strip from max but I don't understand why only 3 lights in the strip are on:
how can I control all that strip using arduino?
You don't make clear which code you actually used, nor provide any patch. At this point your question is not related to Max at all, it's just an Arduino question.
Make sure to declare the right number of leds when you call Adafruit_NeoPixel() (it is the first number). And of course send enough data to feed all declared leds.
In the code from this post, only 3 leds are declared and addressed.
The example from that one is for 100 leds.
Thanks.
after some time playing with it I come with this simple 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 300 // 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
}
}
}
and simple max patch for controlling those leds (on off, random color picker):
Next thing to figure out is how to control those led in sequence running up and down (with same color). Any example to that using Max?
I don't have my example to hand, but I would strongly suggest you use Jitter for this (your last step would be to convert the jitter matrix into a message to be sent to your serial object). You might also find some joy using javascript into a Jitter matrix, depending on your js chops or what you can get an LLM to do for you.