#include #define stripLength 64 // Number of LEDs in your strip // specified under `rate` in the `[device]` section of /etc/boblight.conf #define serialRate 115200 // boblightd sends a prefix (defined in /etc/boblight.conf) before sending the pixel data uint8_t prefix[] = {0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA}; struct CRGB { unsigned char g; unsigned char r; unsigned char b; }; struct CRGB *leds; #define PIN 8 void setup() { FastSPI_LED.setLeds(stripLength); FastSPI_LED.setChipset(CFastSPI_LED::SPI_TM1809); FastSPI_LED.setPin(PIN); FastSPI_LED.init(); FastSPI_LED.start(); Serial.begin(serialRate); } void loop() { // wait until we see the prefix for(byte i = 0; i < sizeof prefix; ++i) { waitLoop: while (!Serial.available()) ;; // look for the next byte in the sequence if we see the one we want if(prefix[i] == Serial.read()) continue; // otherwise, start over i = 0; goto waitLoop; } // read the transmitted data for (uint8_t i = 0; i < stripLength; i++) { byte r, g, b; while(!Serial.available()); r = Serial.read(); while(!Serial.available()); g = Serial.read(); while(!Serial.available()); b = Serial.read(); leds[i].r = r; leds[i].g = g; leds[i].b = b; } FastSPI_LED.show(); }