   }
 }
 
+
   void setOutput( int red, int green, int blue) {
     //"local variable hides a field" :p
-    Driver.begin();
-    Driver.SetColor(red, green, blue);
-    Driver.end();
+
+    if (!SINGLE_LED) {
+      Driver.begin();
+      Driver.SetColor(red, green, blue);
+      Driver.end();
+    } else { //testing setup: single RGB led with cathode on 7
+      analogWrite(6,red);
+      analogWrite(5,green);
+      analogWrite(4,blue);
+    }
   }
 
   void setOutput( int color[]) {
-    if (sizeof(color)!=3) {
-      // log error message
-    } else {
+    Serial.println(color[0]);
+    Serial.println(color[1]);
+    Serial.println(color[2]);
+    Serial.println(color[3]);
+
+     
       setOutput(color[0],color[1],color[2]);
-    }
-  }
-
-// TODO: reuse relevant driver code (like two lines)
-//  while (Serial.available() > 0) {
-//    // each input is in the form 000,123,255\n
-//    
-//    //parseInt skips the first non-digit and non-minus sign chars, so input is split:
-//    red = Serial.parseInt();  // 123
-//    green = Serial.parseInt();// (,)123
-//    blue = Serial.parseInt(); // (,)123
-//    if (Serial.read() == '\n') { //data probably received successfuly
-//      red = constrain(red, 0, 255);
-//      green = constrain(green, 0, 255);
-//      blue = constrain(blue, 0, 255);
-//
-//      Driver.begin();
-//      Driver.SetColor(red, green, blue);
-//      Driver.end();
-//
-//      // report back hex values
-//      Serial.print(red, HEX);
-//      Serial.print(green, HEX);
-//      Serial.println(blue, HEX);
-//
-//      
-//     }
-//  }
-//}
+    
+  }
+
+  void decodeHex( char hexColor[], int output[] ) { // #FFFFFF
+    hexColor[8] = '\0';
+    // function strtol() returns a long when given (string,end pointer,radix)
+    long long number = strtol( &hexColor[1], NULL, 16);   // from Stack Exchange
+    // Split them up into r, g, b values    
+    output[0] = number >> 16;
+    output[1] = number >> 8 & 0xFF;
+    output[2] = number & 0xFF;                           // end SE code
+
+    if (DEBUGGING_MODE) {
+      Serial.println("---decodeHex debugging---");
+      Serial.println("hexColor: ");
+      Serial.println(hexColor);
+      Serial.println("number:");
+      char longOut[30];
+      sprintf(longOut, "%lld", number);
+      Serial.println(longOut);
+      Serial.println("output:");
+      printArray(output);
+      Serial.println();
+      Serial.println("--------------------------");
+      Serial.println();
+    }
+    
+  }
+
+  void printArray( int r[]) {
+    int x=0;
+    while (r[x]!='\0') {
+      Serial.print(r[x]);
+      x++;
+    }
+  }
+  
+
+  void gradientPulse (int col1[], int col2[], float timev) {
+    // in this initial version, gradient pulses are going to be locking.
+    // This is obviously a problem - add an interrupt when you have time.
+    double tick = timev;
+    double percentPerTick = tick/1;
+    for (float percentage = 0; percentage+=percentPerTick; percentage < 1) {
+      gradientValue(col1, col2, percentage,*rgb);
+      setOutput(*rgb);
+    }
+  }
+
+  void gradientValue(int col1[3], int col2[3], float percentage, int output[3]) {
+    output[0] = col1[0]*percentage + col2[0]*(1-percentage);
+    output[1] = col1[1]*percentage + col2[1]*(1-percentage);
+    output[2] = col1[2]*percentage + col2[2]*(1-percentage);
+    
+  }
+
+void p(char *fmt, ... ){
+        char buf[128]; // resulting string limited to 128 chars
+        va_list args;
+        va_start (args, fmt );
+        vsnprintf(buf, 128, fmt, args);
+        va_end (args);
+        Serial.print(buf);
+}
+

 *  ???
 */


static boolean DEBUG = true;


#include "RGBdriver.h"
#define CLK 2 //pin definitions for the driver        
#define DIO 3

        Serial.println(blue, DEC);
        Serial.println("");
        }
        
        break;
      }
    case 'G' : {
        // run gradient pulse between a and b with appropriate timestep; "G#000000:#123456:time" input
        if (input[9]=='#') {
          char hex1[7], hex2[7];
          char timev[7]; //well our buffer is 7 chars now.
          for (int x=0; x<7; x++) {
            hex1[x]=input[x+1];
            hex2[x]=input[x+9];
            timev[x]=input[x+16];
          }
          int col1[4],col2[4];
          decodeHex(hex1,col1);
          decodeHex(hex2,col2);

          float timeVal = atoi(timev); //use strtol or sscanf instead

          gradientPulse(col1,col2,timeVal);

          if (DEBUGGING_MODE) {
            Serial.println(hex1);
            Serial.println(hex2);
            Serial.println(timev);
          }
        } else {
          Serial.println("Error: malformed gradient request");
          Serial.println(input);
        }
        break;
      }
    }
