int i = 0; char buf[20]; int color[5]; // NeoPixel Ring simple sketch (c) 2013 Shae Erisson // Released under the GPLv3 license to match the rest of the // Adafruit NeoPixel library #include #define LED_PIN 32 #define NUM_LEDS 2 #define BRIGHTNESS 200 CRGB leds[NUM_LEDS]; #define DELAYVAL 500 // Time (in milliseconds) to pause between pixels void setup() { // These lines are specifically to support the Adafruit Trinket 5V 16 MHz. // Any other board, you can remove this part (but no harm leaving it): #if defined(__AVR_ATtiny85__) && (F_CPU == 16000000) clock_prescale_set(clock_div_1); #endif // END of Trinket-specific code. Serial.begin(115200); FastLED.addLeds(leds, NUM_LEDS); FastLED.setBrightness(BRIGHTNESS); } void loop() { if (Serial.available()) { // pixels.clear(); // Set all pixel colors to 'off' buf[i] = Serial.read(); if (buf[i] == 'e') { // set 'e' at the end of the last caracter buf[i] = '\0'; //Serial.println(buf); color[0] = atoi(strtok(buf, ",")); color[1] = atoi(strtok(NULL, ",")); // use NULL from second group color[2] = atoi(strtok(NULL, ",")); leds[0] = CRGB(color[0], color[1], color[2]); leds[1] = CRGB(color[0], color[1], color[2]); FastLED.show(); // Send the updated pixel colors to the hardware. //send back data to processing Serial.println("color[0],color[1],color[2]"); // Serial.println(color[1]); // Serial.println(color[2]); i = 0; } else { i++; } } }