int cld1Pin = 4; // Card status pin int rdtPin = 2; // Data pin int reading = 0; // Reading status #define BUFFER_SIZE 700 volatile int overwrite_fu = 0; volatile int buffer[BUFFER_SIZE] = {}; // Buffer for data volatile int i = 0; // Buffer counter volatile int bit = 0; // global bit void setup() { Serial.begin(115200); // The interrupts are key to reliable // reading of the clock and data feed attachInterrupt(0, changeBit, CHANGE); attachInterrupt(1, writeBit, FALLING); } void loop(){ // Active when card present while(digitalRead(cld1Pin) == LOW){ reading = 1; } // Active when read is complete // Reset the buffer if(reading == 1) { for (int x=0; x= BUFFER_SIZE) { Serial.println("buffer overflow detected, perhaps increase the buffer size? FUUUUUUUUUU!"); } else { buffer[i] = bit; i++; } }