analogRead seems to freeze some seconds the program
analogRead() is fine, it takes only about 110&nbsp;µs, but there are
several other issues with your code that you should fix:


Any variable that is shared between interrupt code and normal code
should be declared volatile in order to prevent the compiler to do
some unsafe optimizations.
Any such variable that is more than one byte in size should be
accessed from the main program with interrupts disabled.
You should take care of not writing into databits[] past the end of
the array.
Counting loop iterations is a very bad way of measuring elapsed time,
as the counting speed will change whenever you change your loop code.
Use micros() instead.


There is also an issue with how you use flagDone. You set it to 1,
then you call analogRead(), MicroViewSlider::setValue() and
uView.display(), then you read it back. What if your ISR has set it
back to 0 in the meantime? I suspect this is the main cause of the
problem you see.

I suggest you use flagDone to inhibit the ISRs: the main loop sets it
to true to tell the ISRs “Let's say we are done with this card. Please
do not touch anything while I process the already received information.”
And later it sets it to false meaning “You can proceed reading bits
now.”

Given the above considerations, I would try something along these lines:

volatile bool flagDone;     // if we are done, pause the reading
volatile uint8_t bitCount;  // number of bits received so far
volatile uint32_t rxTime;   // last time we got a bit

// Interrupt that happens when INTO goes low (0 bit).
void ISR_INT0()
{
    if (!flagDone &amp;&amp; bitCount &lt; MAX_BITS) {
        rxTime = micros();
        databits[bitCount++] = 0;
    }
}

// Same thing, but writes 1 instead of 0 into databits[].
void ISR_INT0() { ... }

void loop()
{
    // Safely read rxTime.
    noInterrupts();
    uint32_t rxTimeCopy = rxTime;
    interrupts();

    if (bitCount &gt; 0 &amp;&amp; micros() - rxTimeCopy &gt;= WEIGAND_WAIT_TIME) {
        // Assume we are done reading this card.
        flagDone = true;

        // Do whatever with databits[].
        // ...

        // Get ready for the next card.
        bitCount = 0;
        flagDone = false;  // do this last: it re-enables the ISR
    }
}