 #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 EEPROM_SIZE 1024
+
+//#include <SoftwareSerial.h>
+//SoftwareSerial Serial2(2, 3); // RX, TX
 
 #define TRANSMISSION_ATTEMPTS 10
 #define TRANSMISSION_REPEATS 5
 #define TRANSMISSION_SPACE 95
 #define TRANSMISSION_ATOM_SIZE 3
+
 uint8_t recieve_error;
+
+MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
+uint32_t lastCardScan; // Debounce RFID reads
+const uint8_t timeBetweenScans = 200;
+uint16_t credits_in_machine;//Serial.parseInt();
+
+const uint8_t speakerOutPin = 9;
+
+void setup() {
+  //Serial2.begin(19200);
+
+#if 0 // Set this to 1 to set the entire EEPROM to 0 (default is 0xFF)
+  for (uint16_t i = 0; i < EEPROM_SIZE; i++)
+    EEPROM_writeAnything(i, 0);
+  Serial2.println(F("EEPROM cleared"));
+  while(1);
+#endif
+
+  //Serial2.println(F("Started"));
+  
+  lastCardScan = 0;
+  
+  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(speakerOutPin, OUTPUT); // speaker out
+}
 
 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)){
+    /*for (uint8_t i = 0; i < sizeof(parseBuffer); i++) {
+      Serial2.print(parseBuffer[i], HEX);
+      Serial2.write(' ');
+    }
+    Serial2.println();*/
+
     // 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){

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

  // Now a card is selected. The UID and SAK is in mfrc522.uid.

  // Dump UID
    if(millis() - lastCardScan > timeBetweenScans){
      lastCardScan = millis();
      // Some user feedback
      BEEP(1);
