hello,
i have a project that uses a bunch of rgb led strips (http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Components/LED/FLB%205060RGB%201m%20%20FLEX%20STRIP.pdf) controlled by an arduino and the FASTSPI_LED library. i have a second arduino running a loop that provides a oscillating number from 0 -150 that gets sent to the first arduino via txrx and the EASYTRANSFER library. here is the loop-
if button is pressed->make the first led light up with whatever value is coming in from second arduino->move the led down one position->repeat this process until the button is released (creates a chasing effect of leds moving down the strip)
if button is released->turn off first led->move led down one position->repeat until button is pressed again (turns off leds one by one)
this loop takes each new value coming in and moves it down the line of leds, making it appear to be pulsing but in reality its just a bunch of lights changing position down a line (like a stadium of people doing the wave, each person doing whatever the person before did)
what i would like to achieve is a loop that when the button is pressed, a group of leds turns on and moves down the strips, pulsating the live value changes from the second arduino. (like a small group of people moving around the stadium doing the wave based on what amount of wave they are told to do, which is constantly changing)
heres the code im currently working with
#include <FastSPI_LED.h>
#include <EasyTransfer.h>
#define NUM_LEDS 160
struct CRGB {
unsigned char r;
unsigned char g;
unsigned char b;
};
struct CRGB *leds;
#define PIN 4
EasyTransfer ET;
struct RECEIVE_DATA_STRUCTURE{
//put your variable definitions here for the data you want to receive
//THIS MUST BE EXACTLY THE SAME ON THE OTHER ARDUINO
int fade;
};
//give a name to the group of data
RECEIVE_DATA_STRUCTURE mydata;
void setup() {Serial.begin(9600);
ET.begin(details(mydata), &Serial);
pinMode(5, 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() {
ET.receiveData();
int button = analogRead(5);
// If the button is down, insert an incoming value (mydata.fade) at the beginning of the strip
if(button < 900) {
leds[0].r = mydata.fade;
leds[0].g = mydata.fade;
leds[0].b = mydata.fade;
}
FastSPI_LED.show();
delay(10);
// Show the current pattern
// 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;
}
if (button < 900){ //if button is released, turn the first led off
leds[0].r = 0;
leds[0].g = 0;
leds[0].b = 0;
}
FastSPI_LED.show();
delay(20);
}
any ideas or nudges in the right direction would be very helpful.
thanks, tom