   
 }
 
+void dim1(){
+    for (int i=0; i<100; i++) {
+      dimLow((float) i / 100);
+      delay(15);
+    }
+}
+
+void dim2(){
+      for (int j=0; j<=100; j++) {
+      dimHigh((float) j / 100);
+      delay(15);
+    }   
+}
+
+void dim3(){
+      for (int j=100; j>=0; j--) {
+      dimHigh((float) j / 100);
+      delay(15);
+    }   
+}
+
+void dim4(){
+      for (int j=100; j>=0; j--) {
+      dimLow((float) j / 100);
+      delay(15);
+    }   
+}
+
+int oldRed = 0;
+int oldGreen = 0;
+int oldBlue = 0;
+
 void stripColor(int newRed, int newGreen, int newBlue){
-  red = newRed;
-  green = newGreen;
-  blue = newBlue;  
+  if (newRed != oldRed) {analogWrite(redPin,newRed); oldRed = newRed; }
+  if (newGreen != oldGreen) {analogWrite(greenPin,newGreen); oldGreen = newGreen; }
+  if (newBlue != oldBlue) {analogWrite(bluePin,newBlue); oldBlue = newBlue; }
 }
 
 void dimHigh(float dim) {

int calcDim(int low, int high, float dim) {
  return (0.5 + low + dim * (high-low));
}


const int redPin   = 9;
const int greenPin = 10;
const int bluePin  = 11;

int lowRed   = 22;
int lowGreen = 5;
int lowBlue  = 0;

int highRed  = 255;
int highGreen= 245;
int highBlue = 45;

void setup() {
//  Serial.begin(57600);
  
  pinMode(redPin, OUTPUT); 
  pinMode(greenPin, OUTPUT); 
  pinMode(bluePin, OUTPUT); 

  stripColor(0,0,0);
}

void loop() {

    dimLow(0);
    delay(1000);

    dim1();
    delay(1000);
    dim2();
    delay(1000);
    dim3();
    delay(1000);
    dim4();
    delay(1000);

//  while (Serial.available() > 0){
//    char c = Serial.read();
//    
