         } else { // Known card!
           // Card found!
           // Withdraw from card
-          uint16_t credit_addr = addr+CARD_UID_SIZE;
-          EEPROM_readAnything(credit_addr,card.credits);
+          EEPROM_readAnything(addr+sizeof(card_uid_t),card.credits);
           if(card.credits == 0){
             // ERR Beep + display "NO CREDITS"?
             Serial.println("NO CREDITS - KNOWN CARD");


int16_t findFreeCardSpot(){
  uint16_t credits = 0;
  uint16_t addr = CARD_UID_SIZE; // Offset pointer, so we are looking at the card.credits
  uint16_t last_addr = 1024-sizeof(card_t); // EEPROM size minus size of one element
  for(addr; addr <= last_addr; addr = addr + sizeof(card_t)){
    if(EEPROM_compareAnything(addr,credits)){ // If bytes at address match, ok!
      Serial.println(addr-CARD_UID_SIZE);
      return addr-CARD_UID_SIZE; // Offset pointer again, so it points to beginning of card_t
    }
  }
  return 65535; // Error value

#include "VendingMachineRFID.h"

/* Hack to fix sizeof(card_uid_t) sometimes becoming 5 (?) */
// #define CARD_UID_SIZE 4
// Caused by Stream.parseInt();

MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
uint32_t lastCardScan; // Debounce RFID reads
uint32_t timeBetweenScans;

uint16_t credits_in_machine;//Serial.parseInt();
char parseBuffer[2];

void setup() {
  uint32_t lastCardScan = 0;
