     else {  // pin_type == 'd'
 
         // CHECK INDEX BOUNDS
-        if (pin_index < 0 || pin_index >= NUM_DIGITAL_PINS) {
+        if (cmd_index < 0 || cmd_index >= NUM_DIGITAL_VALS) {
             Serial.print("Index out of range.\n");
             return;
         }
 
-        // READ PIN VALUE
-        pin_value = Serial.read();
-        if (pin_value < 0 || pin_value > 1) {
-            Serial.print("Pin value out of range.\n");
+        // READ CMD VALUE
+        cmd_value = Serial.read();
+        if (cmd_value < 0 || cmd_value > 1) {
+            Serial.print("cmd value out of range.\n");
             return;
         }
 
-        // WRITE TO PIN
-        if (pin_index == 0) {
-            digitalWrite(DIGITAL_PIN_0, pin_value);
-        }
-        else if (pin_index == 1) {
-            digitalWrite(DIGITAL_PIN_1, pin_value);
+        // COMPUTE
+        else {
+            compute();
         }
     }
-
-    //////////////////////////
-    //   SEND CONFIRMATION  //
-    //////////////////////////
-    //sprintf(buffer, "%u %u\n", pin_index, pin_value);
-    //Serial.print(buffer);
-
-    // delay(LOOP_DELAY);  // IS THIS NEEDED?
-}
-
-void processing() {
-    ;
-}
-
-void loop() {
-    txrx();
-    processing();
 }
 
 

    if (! Serial.available()) {
        return;
    }
    pin_type = Serial.read();
    if (pin_type != 'a' && pin_type != 'd') {
        Serial.print("Invalid pin type.\n");
        return;
    }
    delay(SERIAL_DELAY);  // WAIT FOR PIN INDEX AND VALUE

    if (! Serial.available()) {
        return;
    }

    pin_index = Serial.read();

    if (! Serial.available()) {
        return;

    //////////////////////////
    //    ANALOG PIN        //
    //////////////////////////
    if (cmd_type == 'a') {

        // CHECK INDEX BOUNDS
        if (cmd_index < 0 || cmd_index >= NUM_ANALOG_VALS) {
            Serial.print("Index out of range.\n");
            return;
        }

        // READ CMD VALUE
        cmd_value = Serial.read();
        if (cmd_value < 0 || cmd_value > ANALOG_HI) {
            Serial.print("cmd value out of range.\n");
            return;
        }

        // COMPUTE
        else {
            compute();
        }
    }

