 */
 unsigned long accumulator(void) {
 	unsigned long startTime, endTime = 0;
-	int pollCounter = 0;
+	unsigned long pollCounter = 0;
 	int signalState;
 	int previousState;
-	bool cardPresent;
+	unsigned char A[bufferSize];
 
 	while(1) {
 		// poll for card
 		MF_SNR();
-		cardPresent = getResponse();
-		delay(cardTimeout);
-		pollCounter += 1;
-		if(!getResponse()) {
-			Serial.println("Card not detected.");
-			return 0;
+		if(!getResponse(A)) {
+			delay(cardTimeout);
+			if(!getResponse(A)) {
+				Serial.println("Card not detected.");
+				return 0;
+			}
 		}
 
 		// read signal state

	}


	// Write time data to card
	MF_WRITE(0x01, 0x05, elapsedTime);
	delay(200);
	responseFlag = getResponse(readData);
	if(responseFlag == false) Serial.println("Unexpected result");
	

}

// Start and End bytes for command/response packets
#define STX 0xAA
#define ETX 0xBB
#define MSB 0xFF

// MiFare Classic commands
#define CMD_READ 0x20
