//https://wokwi.com/projects/388535837079145473
// See README.md or Description tab
// adjust the clock frequency in th diagram.json file
// adjust the scope parameters from a scope click or .json 
const byte ClockPin = 2;
byte lastClockState = -1;

long changes = 0;

void setup() {
  pinMode(ClockPin, INPUT);
  Serial.begin(115200);
}

void loop() {
  // do https://forum.arduino.cc/t/demonstration-code-for-several-things-at-the-same-time/217158
  clockCheck();
  report();
  //Serial.print("L");
}

bool clockCheck(void){
  byte clockMode = digitalRead(ClockPin);
  if (clockMode != lastClockState) {
    ++changes;
    //Serial.print('x'); // change
    lastClockState = clockMode;
    Serial.print(clockMode == HIGH ? '^' : 'v'); // rising or falling
  }
}

void report(void){
  const unsigned long interval = 1000;
  static unsigned long last=-interval;
  unsigned long now = millis();
  if(now - last >= interval){
    Serial.print("\nChanges:");
    Serial.print(changes);
    Serial.print(" freq_mHz:");
    Serial.print(1000.0*changes/2);
    Serial.print(" period_ms:");
    Serial.print(2*1000.0*1000/changes/interval);
    Serial.print(" ");
    changes = 0;
    last = now;
  }
}
9.43
Loading chip...chip-scope

ERC Warnings

flop1:CLK: Clock driven by combinatorial logic