       }
       mask = mask << 1;
     }
+    Serial.println(F("Write digital"));
     writePort(port, (byte)value, pinWriteMask);
   }
 }

    }
    break;
  default:
    BLE_Firmata.sendString("Unknown pin mode"); // TODO: put error msgs in EEPROM
  }
  // TODO: save status to EEPROM here, if changed
}

  /* Using non-looping code allows constants to be given to readPort().
   * The compiler will apply substantial optimizations if the inputs
   * to readPort() are compile-time constants. */
  for (uint8_t i=0; i<TOTAL_PORTS; i++) {
    if (reportPINs[i]) {
    //  Serial.print("Reporting on port"); Serial.println(i);
      uint8_t x = readPort(i, portConfigInputs[i]);
    //  Serial.print("Read 0x"); Serial.println(x, HEX);
      outputPort(i, x, false);
    }
  }
}

// -----------------------------------------------------------------------------
