const int NLEDS = 4; const int LEDPINS[NLEDS] = { 3,5,6,11}; // Need to be PWM pins! const int NSWITCHES = 4; const int SWITCHPINS[NSWITCHES] = { 8,9,10,12}; // skip 11 because we need it as a PWM LED pin const int STATUSLEDPIN = 13; // onboard LED const int SPEEDPOTPIN = 5; // analog potentiometer pin const int NuSTEPS = 4; // microsteps between pattern steps const int MINuSTEPSIZE = 15; // when POTPIN is 255 const int MAXuSTEPSIZE = 30; // when POTPIN is 0 int uStepSize; const int NPATTERNS = 2*(NSWITCHES-1); // SWITCHPINS[0] is "shift key", so we have 6 instead of 4 :) const int PATTERNLOOKUP[NPATTERNS+1] = { // indices into PATTERNDATA below 0,4,8,12,16,24,25}; // one extra index to tell the length of last pattern const int PATTERNDATA[][NLEDS]={ // 0: 0-3 chase { 255,0,0,0 } ,{ 0,255,0,0 } ,{ 0,0,255,0 } ,{ 0,0,0,255 } , // 1: 4-7 fade in { 255,255,255,255 } ,{ 0,0,0,0 } ,{ 0,0,0,0 } ,{ 0,0,0,0 } , // 2: 8-11 chase+fade { 0,0,0,255 } ,{ 0,0,255,127 } ,{ 0,255,127,63 } ,{ 255,127,63,0 } , // 3: 12-15 explode { 0,255,255,0 } ,{ 127,63,63,127 } ,{ 63,0,0,63 } ,{ 0,0,0,0 } , // 4: 16-23 slow fade { 255,255,255,255 } ,{ 191,191,191,191 } ,{ 127,127,127,127 } ,{ 0,0,0,0 } , { 0,0,0,0 } ,{ 127,127,127,127 } ,{ 191,191,191,191 } ,{ 255,255,255,255 } , // 5: 24 dark (for my wife's sake) { 0,0,0,0 } , }; const int DEFAULTPAT = 5; // dark int curPat; const int SHIFTUP = 0; const int SHIFTDOWN = 1; const int SHIFTUSED = 2; int shiftState; int switchesFree; // true if no switch was pressed (except maybe the shift) unsigned long timeBase; // used for syncing the patterns when switch is pressed unsigned long seqBase; // absolute start of sequencer record or playback unsigned long shiftDownTime; // time shift key went down. *Might* become seqBase int recordMode; // true if we're recording const int MAXSEQSIZE = 32; int seqPats[MAXSEQSIZE]; int seqEnds[MAXSEQSIZE]; // millis from start of seq, cummulative int seqSize; // length of the recorded sequence int seqIndex; // where we are at the playback void setup() { //Serial.begin(9600); for (int i=0 ; i=0) { seqEnds[seqSize] = endTime-seqBase; } if (seqSize"); //Serial.println(curPat,DEC); } break; } } }