         TCCR1C = 0;
         TCNT1 = 0;
         TIMSK1 = 0;
+
+        TCCR3A = 0;
+        TCCR3B = 5;
+        TCCR3C = 0;
+        TCNT3 = 0;
+        TIMSK3 = 0;
 }
 
 void loop() {
-        static int mode = MODE_STATIC, strobe_on = 0, flash = 0;
-        static float smooth_hue = 0, brightness = 1, strobe = 0, fade = 0,
-                        static_r = 0, static_g = 0, static_b = 0,
-                        fade1_r = 0, fade1_g = 0, fade1_b = 0,
-                        fade2_r = 0, fade2_g = 0, fade2_b = 0;
+        enum {
+                MODE_STATIC,
+                MODE_SMOOTH,
+                MODE_FLASH,
+                MODE_FADE
+        };
+
+        const float SMOOTH_FREQ = 0.05,
+                    FADE_FREQ = 0.1,
+                    STROBE_FREQ = 3,
+                    FLASH_FREQ = 4;
+
+        static int mode = MODE_STATIC, strobe_on = 0;
+        static float brightness = 1, time = 0, strobe = 0,
+                     a_r = 0, a_g = 0, a_b = 0,
+                     b_r = 0, b_g = 0, b_b = 0;
 
         int cmd = command;
         command = 0;
 
+        if (cmd) {
+                Serial.print("IR command: ");
+                Serial.println(command2string(cmd));
+        }
+
+        float elapsed = timer3() * (1024 / 1.6e7);
+        time += elapsed;
+
         switch (cmd) {
         case LIGHT_RED:
-                static_r = 1;
-                static_g = static_b = 0;
+                a_r = 1;
+                a_g = a_b = 0;
                 mode = MODE_STATIC;
                 break;
         case LIGHT_GREEN:
-                static_r = static_b = 0;
-                static_g = 1;
+                a_r = a_b = 0;
+                a_g = 1;
                 mode = MODE_STATIC;
                 break;
         case LIGHT_BLUE:
-                static_r = static_g = 0;
-                static_b = 1;
+                a_r = a_g = 0;
+                a_b = 1;
                 mode = MODE_STATIC;
                 break;
         case LIGHT_SMOOTH:
                 mode = MODE_SMOOTH;
                 break;
         case LIGHT_OFF:
-                static_r = static_g = static_b = 0;
+                a_r = a_g = a_b = 0;
                 mode = MODE_STATIC;
                 break;
         case LIGHT_BRIGHTER:

        }
}

void decode() {
        static volatile int bits = 0;
        static volatile unsigned char data[4];

                                last_command = command;
                        }
                } else {
                        state = DATA_LOW;
                }
                break;
