     Serial.print(gradPerc);
     Serial.println("/1");
     gradientValue(gradcol1, gradcol2, gradPerc, rgb);
-    setOutput(rgb);
+    outputColor(rgb);
     gradPerc+=gradPercPerTick;
   }
   else {
     if (gradientLoop) {
       gradPerc = 0;
+      if (gradientMode) {
+        int temp[3]; //swap 1 and 2
+        arrayCopy(temp,gradcol1,3);
+        arrayCopy(gradcol1,gradcol2,3);
+        arrayCopy(gradcol2,temp,3);
+      }
       if (debugMode) { Serial.println("Looping gradient."); }
     } else {
       if (debugMode) { Serial.println("Halting gradient."); }

  setValue(0,0,0);
}


void setOutput( int r, int g, int b) {

  if (!SINGLE_LED) {
    Driver.begin();
    Driver.SetColor(r, g, b);
    Driver.end();
  } else {
    analogWrite(R_PIN,r);
    analogWrite(G_PIN,g);
    analogWrite(B_PIN,b);
  }
}



void setOutput( int *color[]) {  
  if (debugMode) {
    Serial.println(); // for some reason a lot of this output
    Serial.println("---Setting output:---"); // doesn't show up
    Serial.println(*color[0]);
    Serial.println(*color[1]);
    Serial.println(*color[2]);
    Serial.println(*color[3]);
    Serial.println("---------------------");
  }
    setOutput(*color[0],*color[1],*color[2]);
}

void setValue ( int r, int g, int b) {
  gradientThread.disable(); // cut off anything else
  gradientLoop = false;  
  red=r; green=g; blue=b;
  setOutput(rgb);
}

void clearBuffer() {
  //optimized for a mostly empty buffer
  char *ptr = &inputBuffer[0];
  if(debugMode) {
    Serial.print("Buffer: [");
    while (ptr<&inputBuffer[0]+SERIAL_BUFFER_LENGTH && *ptr!=0) {
      Serial.print(*ptr);
      *ptr = 0;
      ptr++;
    }
    Serial.print(*ptr);
    Serial.println( "] wiped.");
  } else {
    while (ptr<&inputBuffer[0]+SERIAL_BUFFER_LENGTH && *ptr!=0) {
      *ptr = 0;
      ptr++;
    }
  }
  *ptr = 0;
}


    pinMode(GND,OUTPUT);
  }
  gradientThread.disable();
  flashThread.disable();
  Serial.setTimeout(SERIAL_CYCLE_LENGTH/7); //should be substantially less than serialThread's execution window
  Serial.begin(BAUDRATE);
  quickCycle(25); // power-up notification
}
