Reading data at 10 Khz rate

Hi

Two obvious things I think to look at - firstly clock1 isn't initialised, so first pass through it won't have a reliable value. You can fix that in your declaration:

int clock1 = 0;

And the other part is you don't want to set clock1 at the end of the loop to whatever the digital pin value is, but rather what clock was. Like this:

      clock1 = digitalRead(pin2);
// becomes
      clock1 = clock;

Just two thoughts to start you off :slight_smile:

Geoff