     digitalWrite(pin, LOW);
   }
 }
+
+int countColor(unsigned long millis, int shift) {
+  int t = (millis + shift) % crude_T;
+
+  if (0 <= t && t <= 2*crude_Ts) {
+    return 0;
+  } else if (3*crude_Ts <= t && t <= 5*crude_Ts) {
+    return crude_I;
+  } else if (2*crude_Ts <= t && t <= 3*crude_Ts) {
+    return (int)(crude_I * (t - 2*crude_Ts) / crude_Ts);
+  } else if (5*crude_Ts <= t && t <= 6*crude_Ts) {
+    return (int)(crude_I - crude_I * (t - 5*crude_Ts) / crude_Ts);
+  } else {
+    return 0;
+  }
+}


#define EMPTY_COMMAND_SUCCESS " "
#define EMPTY_COMMAND_FAIL ""

void setup() {
  pinMode(PIN_RED, OUTPUT);


    setColor(r, g, b);

    setLightMode(STATIC);

    return EMPTY_COMMAND_SUCCESS;
  } else if (command.equals("CRUDE_LIGHT")) {
    lightModeStart = millis();
    setLightMode(CRUDE);
    return EMPTY_COMMAND_SUCCESS;
  } else if (command.startsWith("VERSION")) {
    return FIRMWARE_VERSION;
  }

  return EMPTY_COMMAND_FAIL;
}

void setLightMode(LightMode mode) {
  lightMode = mode;
}

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