sorry for the poor description.
so right now, when the button is pressed, an led goes fading down the strip. i have a max/msp patch constantly feeding the arduino a value for the led. when the button is pressed, it only shoots one of these random values down the strip. i want it so that when the led goes fading down the strip, it keeps changing with the live values it is receiving via max/msp, instead of just one received value.
hope that makes some sense.
heres my code-
#include <FastSPI_LED.h>
#define NUM_LEDS 288
struct CRGB {
unsigned char r;
unsigned char g;
unsigned char b;
};
struct CRGB *leds;
long RAND;
#define PIN 4
void setup() {
Serial.begin(115200);
pinMode(5, INPUT);
pinMode(0, INPUT);
FastSPI_LED.setLeds(NUM_LEDS);
FastSPI_LED.setChipset(CFastSPI_LED::SPI_WS2801);
FastSPI_LED.setDataRate(3);
//FastSPI_LED.setChipset(CFastSPI_LED::SPI_LPD6803);
//FastSPI_LED.setChipset(CFastSPI_LED::SPI_HL1606);
//FastSPI_LED.setChipset(CFastSPI_LED::SPI_595);
//FastSPI_LED.setChipset(CFastSPI_LED::SPI_WS2801);
FastSPI_LED.setPin(PIN);
FastSPI_LED.init();
FastSPI_LED.start();
leds = (struct CRGB*)FastSPI_LED.getRGBData();
memset(leds, 0, NUM_LEDS * 3);
}
void loop() {
int button = analogRead(5);
if (Serial.available()>=1) {
RAND=Serial.read();
if(button > 1000) {
leds[0].r = RAND;
leds[0].g = RAND;
leds[0].b = RAND;
}
// Move all the lights down one step
for(int i = NUM_LEDS-1; i > 0; i-- ) {
leds[i].r = leds[i-1].r;
leds[i].g = leds[i-1].g;
leds[i].b = leds[i-1].b;
}
leds[0].r /= 2;
leds[0].g /= 2;
leds[0].b /= 2;
}
FastSPI_LED.show();
delay(30);
}