Hi ! Any tip for trigger fastled patterns thought serial port?
We don’t know what your level of experience is. Do you have any experience reading serial input?
Check for serial each time around in your main loop. Set a variable based on what you read. You could then use a switch case to choose the pattern or plug your selected pattern choice into something like the demoreel100 example.
Put your code on http://gist.github.com and share the link when you run into trouble.
yes, I’m able to transmit several strings of data (positing, brightness and RGB) from Max Msp to Arduino at the same time.
#include<FastLED.h>
#define NUM_LEDS 8
CRGBArray<NUM_LEDS> Cleds;
CRGBArray<NUM_LEDS> Aleds;
CRGBArray<NUM_LEDS> Bleds;
int place = 0;
int hue = 100;
int saturation = 255;
int brightness = 255;
int place1 = 0;
int hue1 = 100;
int saturation1 = 255;
int brightness1 = 255;
int place2 = 0;
int hue2 = 100;
int saturation2 = 255;
int brightness2 = 255;
void setup() {
Serial.begin(9600); // initialize serial communication
Serial.setTimeout(10); // set serial timeout
FastLED.addLeds<NEOPIXEL,13>(Cleds, NUM_LEDS);
FastLED.addLeds<NEOPIXEL,6>(Aleds, NUM_LEDS);
FastLED.addLeds<NEOPIXEL,5>(Bleds, NUM_LEDS);
}
void loop(){
// listen for serial:
if (Serial.available() > 0) {
//if (Serial.read() == ‘C’) { // string should start with C
switch(Serial.read()){
case 'C':
place = Serial.parseInt();
hue = Serial.parseInt(); // then an ASCII number for HUE=PITCH
saturation = Serial.parseInt(); // then an ASCII number
brightness = Serial.parseInt(); // then an ASCII number for BRIGHTNESS=VELOCITY
Serial.println(place);
Serial.println(hue);
Serial.println(saturation);
Serial.println(brightness);
Cleds[place] = CHSV(hue,saturation,brightness);
FastLED.delay(1);
//delayMicroseconds(5000);
//leds[place] = CHSV(0,0,0);
//FastLED.delay(lenght);
break;
case 'A':
place1 = Serial.parseInt();
hue1 = Serial.parseInt(); // then an ASCII number for HUE=PITCH
saturation1 = Serial.parseInt(); // then an ASCII number
brightness1 = Serial.parseInt(); // then an ASCII number for BRIGHTNESS=VELOCITY
Serial.println(place1);
Serial.println(hue1);
Serial.println(saturation1);
Serial.println(brightness1);
Aleds[place1] = CHSV(hue1,saturation1,brightness1);
FastLED.delay(1);
break;
case ‘B’:
place2 = Serial.parseInt();
hue2 = Serial.parseInt(); // then an ASCII number for HUE=PITCH
saturation2 = Serial.parseInt(); // then an ASCII number
brightness2 = Serial.parseInt(); // then an ASCII number for BRIGHTNESS=VELOCITY
Serial.println(place2);
Serial.println(hue2);
Serial.println(saturation2);
Serial.println(brightness2);
Bleds[place2] = CHSV(hue2,saturation2,brightness2);
FastLED.delay(1);
break;
}
}
}
What do you mean with ‘‘plug your selected pattern choice into something like the demoreel100 example’’? thanx
I use the EasyTransfer library for this. as it handles parsing your serial message into variables and does CRC.
@jordi_puigvert Here’s the demoreel100 example:
+1 EasyTransfer. SoftwareSerial support, too.
thnx, i will try
any example using easy transfer and max msp?
If your using two teensy 3.2’s I believe I have a minimal example.
You can communicate with different micro-controllers but order of variables in your easytransfer message and primitive sizes have to be considered so I can’t guarantee my example will work with other setup without minor changes…
Actually I cant guarantee my example will work but I believe this was the example that was working for me when I was investigating using this. Speed will depend on hardware limit. I think teensy can do somewhere near 4Mb/s. I’m doing 1Megabit/s on a current project quite happily.
thankx Gibbedy G. I’m using Max msp to generate midi data and one arduino mega to collect these data, do you think using EasyTransfer is the best way?
I thought msp was some speed acronym or something.
Probably not as i imagine you don’t have easy transfer library on max msp.