         }
       }
     }
-    if (running == 0 || errorcode != 0) finished = true;
-  }
-
-
-  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
+  }
+
+
+  int r0 = ARM_DWT_CYCCNT;
+  digitalWrite(LED_PIN, HIGH);   // turn the LED on (HIGH is the voltage level)
   int m = micros();
   int n = 100000;
-  while (micros() - m < n) {};
-  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
+  while ((int)micros() - m < n) {};
+  digitalWrite(LED_PIN, LOW);    // turn the LED off by making the voltage LOW
   m = micros();
   n = 900000;
-  while (micros() - m < n) {};
+  while ((int)micros() - m < n) {};
   int r = ARM_DWT_CYCCNT;
   Serial.println(r - r0);
-  Serial.println(micros() - fix);
   Serial.send_now();
 }
-

};

struct Protocol {
  Dura t;
  Dura d;
  Dura y;
  Dura n;
  Dura p;
  Dura q;
  byte i;
  byte s;
  byte next;
  byte unused0;
}

struct State {
  Dura t;
  Dura yn;
  Dura pq;
  byte i;
  byte s;
  byte protocol;
  byte runlevel;
  byte pin;
  byte unused0;
  byte unused1;
  byte unused2;
};

int proto_i = 0;
Protocol protocols[PROT];

State channels[CHAN];

int errormsgN = 12;
byte errormsg[12];

char buf[63];

void read_my_eeprom() {
  // Make sure the EEPROM corresponds to the expected device
  int i = 0;
  for (; i < eepsigN; i++) if (EEPROM.read(i) != eepsig[i]) {
    char *msg = "wrong-ver"
    runlevel = 255;
    for (int j = 0; j < 9; j++) errormsg[j] = msg[j];
    for (; j < errormsgN; j++) errormsg[j] = ' ';
    return;
  }

 */

#include <EEPROM.h>
#include <math.h>

int eepsigN = 8;
int idN = 12;
