           if(card.credits == 0){
             // ERR Beep + display "NO CREDITS"?
             //Serial.println("NO CREDITS - KNOWN CARD");
-            Serial.print("N");
+            Serial.write('N');
             BEEP(1);
             // Halt PICC
             mfrc522.PICC_HaltA();

#include "EEPROMAnything.h"
#include "VendingMachineRFID.h"

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();

void setup() {
  lastCardScan = 0;
  timeBetweenScans = 200;
  Serial.begin(19200); // Initialize serial communications with master vending arduino
  Serial.setTimeout(200);
  SPI.begin(); // Init SPI bus
  mfrc522.PCD_Init(); // Init MFRC522 card
  pinMode(9, OUTPUT); // speaker out
}

#define TRANSMISSION_ATTEMPTS 10
#define TRANSMISSION_REPEATS 5
#define TRANSMISSION_SPACE 95
#define TRANSMISSION_ATOM_SIZE 3
uint8_t recieve_error;

uint16_t rfid_raw_read(){
  char parseBuffer[TRANSMISSION_REPEATS*TRANSMISSION_ATOM_SIZE];
  uint16_t number = 0;
  recieve_error = 1; // set default to error
  if(Serial.readBytes(parseBuffer, sizeof(parseBuffer)) == sizeof(parseBuffer)){
    // Recieved correct ammount of bytes - check message integrity
    if(memcmp(parseBuffer,parseBuffer+TRANSMISSION_ATOM_SIZE,sizeof(parseBuffer)-TRANSMISSION_ATOM_SIZE) == 0){
      if(parseBuffer[2] == TRANSMISSION_SPACE){

      // Copy card uid
      memcpy(&card.uid, &mfrc522.uid.uidByte, sizeof(card_uid_t));
      uint16_t addr = findCardOffset(card);
      uint16_t credit_addr = addr + sizeof(card_uid_t);
      // Flush incoming buffer
      //while(Serial.available()){Serial.read();}
      // Fetch current credit count for the vending machine, in order to know whether to withdraw or deposit
      credits_in_machine = rfid_recieve('C');
      //Serial.println(addr);
