Controlling WS2811 LED light strip with Arduino Uno in Max
Hello!
I am a college student and very new to working with Max. Right now I am working on a project with the goal of creating a patch that will hopefully let music imported into Max control the LED strip in various ways. I have done a lot of research through these sources:
http://www.instructables.com/id/RGB-LED-Tutorial-using-an-Arduino-RGBL/
https://learn.adafruit.com/adafruit-neopixel-uberguide
https://cycling74.com/forums/connecting-led-light-strip-neopixels-to-max/
However one of the important links from the forum above:
http://www.tigoe.com/pcomp/code/arduinowiring/1172/
No longer leads to the code that has been of great use
I understand the concepts of what I would need to do but am getting lost in the application of it. I even tried using Maxuino but am not sure how to control a strip of LEDs with it. Any guidance in the matter would be greatly appreciated!
Hi Sophie,
I hope this would help you to start.
Best wishes,
Stevie
#include <Adafruit_NeoPixel.h>
#define PIN1 3
String myString;
Adafruit_NeoPixel strip1 = Adafruit_NeoPixel(3, PIN1, NEO_GRB + NEO_KHZ800);
void setup() {
Serial.begin(115200);
strip1.begin();
strip1.show();
}
void loop() {
while (Serial.available() > 0) {
int r0 = Serial.parseInt();
int g0 = Serial.parseInt();
int b0 = Serial.parseInt();
int r1 = Serial.parseInt();
int g1 = Serial.parseInt();
int b1 = Serial.parseInt();
int r2 = Serial.parseInt();
int g2 = Serial.parseInt();
int b2 = Serial.parseInt();
if (Serial.read() == '\n') {
strip1.setPixelColor(0, r0, g0, b0);
strip1.setPixelColor(1, r1, g1, b1);
strip1.setPixelColor(2, r2, g2, b2);
strip1.show();
}
}
}
Thank you! Your patch helped me understand the connection between the two software greatly. However, I do have another question. I am trying to map colors onto specific positions on the LED strip to mimic that of a piano, so when you play a note, it lights up the strip in a specific position and a specific color. But my strip contains 300 LEDs (100 controllable ones). Do you any for loops or maybe recursion that would help me program them?
Just to update this thread, this Arduino code ended up working very well for my project in the end. Couldn't believe how simple it was.
#include <Adafruit_NeoPixel.h>
#define PIN 3
String myString;
Adafruit_NeoPixel strip = Adafruit_NeoPixel(100, PIN, NEO_GRB + NEO_KHZ400);
void setup() {
Serial.begin(115200);
strip.begin();
strip.show();
}
void loop() {
while (Serial.available() > 0) {
int r0 = Serial.parseInt();
int g0 = Serial.parseInt();
int b0 = Serial.parseInt();
int key = Serial.parseInt();
if (Serial.read() == '\n') {
strip.setPixelColor(key, r0, g0, b0);
strip.show();
}
}
}
Hi Sophia
Struggling with the same problem right now, the list u send to your sketch via max would be a 4 number list without comma's where the first 3 are RGB and the last one selects the Led to be illuminated right?
Do you maybe have a solution for when for instance u want to turn on all the 300 Led's at once.
It takes far to long.. It drives me crazy!!
Thanks in Advance ,
Wes