         if (ci->t.s < 0) {
           if (ci->runlevel == 3) turn_off(ci);
           ci->runlevel = 0;
-          runlevel -= 1;
+          running -= 1;
           continue;   // CONTINUE WITH NEXT CHANNEL, THIS ONE IS DONE
         }
         else {

  }
}

void init_pins() {
  if (waveN > 0) analogWriteResolution(12);
  pinMode(LED_PIN, OUTPUT);
  for (int i = 0; i < digiN; i++) pinMode(digi[i], OUTPUT);
}

int tick;
Dura global_clock;
volatile int running;
volatile int errorcode;
volatile bool finished;

void advance(Dura *x, int us) {
  x->u += us;

        }
      }
    }
  }


  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 ((int)micros() - m < n) {};
  digitalWrite(LED_PIN, LOW);    // turn the LED off by making the voltage LOW
  m = micros();
  n = 900000;
  while ((int)micros() - m < n) {};
  int r = ARM_DWT_CYCCNT;
  Serial.println(r - r0);
  Serial.send_now();
}
