 
 
 void activities() {
-
-  int last = atoi(very_active);
-  setPixelColorByRange(0, last, 255,0,255);
-  setPixelColorByRange(last, last+atoi(sendentary), 255,0,0);
+  int last = 0;
+  last = atoi(sleep_time);
+  strip.setBrightness(100);
+  setPixelColorByRange(0, last, 0,0,255);
+  setPixelColorByRange(last, last+atoi(sendentary), 0,255,255);
   last+=atoi(sendentary);
-  setPixelColorByRange(last, last+atoi(fairly_active), 255,255,0);
+  setPixelColorByRange(last, last+atoi(lightly_active), 255,255,0);
+  last+=atoi(lightly_active);
+  setPixelColorByRange(last, last+atoi(fairly_active), 255,155,0);
   last+=atoi(fairly_active);
-  setPixelColorByRange(last, last+atoi(lightly_active), 0,255,255);
-  last+=atoi(lightly_active);
-  setPixelColorByRange(last, last+atoi(sleep_time), 255,155,0);
-  strip.setBrightness(100);
-  strip.show();
+  setPixelColorByRange(last, last+atoi(very_active), 255,0,0);
 }
 
 void setPixelColorByRange(int start, int _end, int r, int g, int b){
-  for(uint16_t i=start; i<_end; i++) {
-    strip.setPixelColor(i,strip.Color(r, g, b));  
+  while(start<_end) {
+    if(waitTime(&flashTimeMark, 10)){
+      strip.setPixelColor(start,strip.Color(r, g, b));
+      strip.show();
+      start++;
+    }   
   }
 }
 

}


// t: current time, b: beginning value, c: change in value, d: duration
float linearTween (float t, float b, float c, float d) {
  return c*t/d + b;
}

  strip.show();
}

int index = 0;
void loop() {
  Bridge.get("r", rChar, 256);
  Bridge.get("g", gChar, 256);
  Bridge.get("b", bChar, 256);

  Bridge.get("pattern", pattern, 2);
  Bridge.get("mode", mode, 2);
  Bridge.get("sleep_time", sleep_time, 5);
