My friend helped me write this code to increment and decrement between colors on RGB LED strips using a shiftbar. I'm a mega-noobie with classes and there's a bunch of syntax that I don't get. The code wont compile and the error message is: "expected "]" before ";" token. Any help most welcome!
Here's the current program:
#include <FunctionWrangler.h>
#include <ShiftBar.h>
#define N_LED 12;
#define PIN_LEDDATA 11;
#define PIN_LEDCLOCK 13;
#define PIN_LEDLATCH 9;
#define PIN_LEDENABLE 10;
/*current LED value*/
int vLEDCur[N_LED];
/*destination LED value*/
int vLEDEnd[N_LED];
/*ShiftBar controller*/
ShiftBar sb = ShiftBar(N_LED,PIN_LEDCLOCK,PIN_LEDDATA,PIN_LEDLATCH,PIN_LEDENABLE);
/*FW to call StepLEDs every 100 milliseconds (the last "true" just enables it)*/
FunctionWrangler fwStepLEDs = FunctionWrangler(StepLEDs,100,true);
void setup()
{
/*initialize the LEDs to random values*/
for(i=0; i<N_LED; i++){
vLEDCur[i] = random(0,1023);
vLEDEnd[i] = vLEDCur[i];
}
sb.Set(vLEDCur);
PIN_LEDDATA (pinMode, OUTPUT);
PIN_LEDCLOCK (pinMode, OUTPUT);
PIN_LEDLATCH (pinMode, OUTPUT);
PIN_LEDENABLE (pinMode, OUTPUT);
}
void loop()
{
/*check to see if the StepLED function should be called*/
fwStepLEDs.Check();
}
void StepLEDs()
{
/*step each LED*/
for(i=0; i<N_LED; i++){
/*get the difference and direction of motion*/
int d = vLEDEnd[i]-vLEDCur[i];
int s = sign(d);
/*increment the LED toward the end state*/
vLEDCur[i] += min(5,abs(d))*s;
/*pick a new end state if we're done*/
if(vLEDCur[i]==vLEDEnd[i]){
vLEDEnd[i] = random(0,1023);
}
}
sb.Set(vLEDCur);
}
int sign(int x)
/*return the sign of a number*/
{
return (x>0) ? 1 : ((x<0) ? -1 : 0);
}