void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  Serial.begin(115200);
  // initialize the measurement
  TCCR1B = bit(CS10);
  TCNT1 = 0;
  digitalWrite(LED_BUILTIN, HIGH);
  // take the measurement
  unsigned int cycles = TCNT1;
  // print the result
  Serial.print("Cycles: ");
  Serial.println(cycles - 1);
  Serial.print("Microseconds: ");
  Serial.println((float)(cycles - 1) / 16);
}


void loop() {
  // delay(1000);
  //digitalWrite(LED_BUILTIN, LOW);
  //delay(1000);
}

sketch.ino hosted with by Wokwi