 #define NUM_CONN 3
 
 SoftwareSerial* bus[NUM_CONN];
-
 int RX[NUM_CONN] = {A1, A3, A5};
 int TX[NUM_CONN] = {A0, A2, A4};
+volatile uint8_t *rxPortRegister[NUM_CONN];
+uint8_t rxBitMask[NUM_CONN];
+int activeBus = -1;
+unsigned long listenStartTime = 0;
+#define listenTimeout 20
+
 int coil[NUM_CONN] = {6, 5, 10}; // magnets
 int distanceToSource[NUM_CONN] = {99, 99, 99};
 int shortestDistanceToSource;


void dropConnector() {
  // send out message that we're going to drop a connector
  char c = DROPPING_CONNECTOR;
  for (int i=0; i<NUM_CONN; i++) bus[i]->write(c);

  // pick random connected connector to drop
  // count number of ports with a low distance to source

  if (shortestDistanceToSource<99) {
    if (!lampState) switchLampOn();
    // send shortest distance to ports with a higher distance
    for (int i =0; i<NUM_CONN; i++) if (distanceToSource[i] > shortestDistanceToSource) txWrite(i, shortestDistanceToSource);
    addTimer(500, processEnergy);
  }
  // if not, switch off the lamp and drop connectors if we were cut out
  else {
