22a23,52
> //assignment of Arduino I/O pins
> #define DFPLAYER_TX 3
> #define DFPLAYER_RX 4
> #define MFRC522_RST_PIN 6
> #define MFRC522_SS_PIN 10
> #define buttonPause A2
> #define buttonUp A1
> #define buttonDown A0
> #define busyPin 5 //DFPLAYER
> #define shutdownPin 7
> #define openAnalogPin A7
> //MOSI, MISO, SCK are assigned to D11, D12, D13 on arduino nano (cannot/should not be changed)
> /*MFRC522 pins are assigned as follows
>  * 1 :: 3V3     --> 1
>  * 2 :: RST     --> 2
>  * 3 :: GND     --> 3
>  * 4 :: IRQ     -- not connected
>  * 5 :: MISO    --> 4
>  * 6 :: MOSI    --> 5
>  * 7 :: SCK     --> 6
>  * 8 :: SDA/SS  --> 7
>  */
> #define PIN_SPEAKER_ENABLE 2

> #ifdef FIVEBUTTONS
> #define buttonFourPin A3
> #define buttonFivePin A4
> #endif
> //

26c56
< SoftwareSerial mySoftwareSerial(2, 3); // RX, TX
---
> SoftwareSerial mySoftwareSerial(DFPLAYER_TX, DFPLAYER_RX); // TX, RX
82a113,129
> //-- detection of RFID placement/removal for play/pause function --
> //inspired by https://github.com/miguelbalboa/rfid/wiki/Useful-code-snippets#detection-of-tag-removal
> bool rfid_tag_present_prev = false;
> bool rfid_tag_present = false;
> int _rfid_error_counter = 0;
> bool _tag_found = false;
> byte uidByte_prev[10] = {0};
> //helper variable for workaround (detect tag removal after first check-in)
> bool first_checkin = false;
> //The player resumes album from last position when a previously played tag is placed on the RFID reader.
> //Placing, removing, and placing a tag within two seconds is used to start the current album over again.
> //For this, the following three variables keep track of the time.
> unsigned long lastPlacementTime = 0;  //the last time the tag was placed on the reader
> unsigned long placementDelay = 2000;  //placement tolerance time in ms
> bool placementTimeout = true;         //timeout status to avoid errors due to counter overflow. The timeout is set to 'true' right after the placementDelay is exceeded for the first time.


631,633c678,680
< #define RST_PIN 9                 // Configurable, see typical pin layout above
< #define SS_PIN 10                 // Configurable, see typical pin layout above
< MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522
---
> //#define RST_PIN 9                 // Configurable, see typical pin layout above
> //#define SS_PIN 10                 // Configurable, see typical pin layout above
> MFRC522 mfrc522(MFRC522_SS_PIN, MFRC522_RST_PIN); // Create MFRC522
641c688
< #define buttonPause A0
---
> /*#define buttonPause A0
651c698
< #endif
---
> #endif*/
739c786
<   Serial.println(F("TonUINO Version 2.1"));
---
>   Serial.println(F("TonUINO Version 2.1~tido20200815"));
741a789,802
>   Serial.println(F("Modified by tido, last update on Aug 15, 2020.\n"));

>   pinMode(buttonPause, INPUT_PULLUP);
>   pinMode(buttonUp, INPUT_PULLUP);
>   pinMode(buttonDown, INPUT_PULLUP);
> #ifdef FIVEBUTTONS
>   pinMode(buttonFourPin, INPUT_PULLUP);
>   pinMode(buttonFivePin, INPUT_PULLUP);
> #endif
>   pinMode(shutdownPin, OUTPUT);
>   digitalWrite(shutdownPin, LOW);

>   pinMode(PIN_SPEAKER_ENABLE, OUTPUT);            // output speaker on/off switch
>   digitalWrite(PIN_SPEAKER_ENABLE, LOW);          // speaker off during bootup
765,766c826
<   mfrc522
<   .PCD_DumpVersionToSerial(); // Show details of PCD - MFRC522 Card Reader
---
>   mfrc522.PCD_DumpVersionToSerial(); // Show details of PCD - MFRC522 Card Reader
771,779c831,832
<   pinMode(buttonPause, INPUT_PULLUP);
<   pinMode(buttonUp, INPUT_PULLUP);
<   pinMode(buttonDown, INPUT_PULLUP);
< #ifdef FIVEBUTTONS
<   pinMode(buttonFourPin, INPUT_PULLUP);
<   pinMode(buttonFivePin, INPUT_PULLUP);
< #endif
<   pinMode(shutdownPin, OUTPUT);
<   digitalWrite(shutdownPin, LOW);
---
>   //turn on speaker after initialization of DFPlayer to prevent clicking during startup
>   digitalWrite(PIN_SPEAKER_ENABLE, HIGH);
947a1001

949d1002
<   do {
970c1023
<       break;
---
>     return;
1093d1145
<   } while (!mfrc522.PICC_IsNewCardPresent());
1095d1146
<   // RFID Karte wurde aufgelegt
1097c1148,1176
<   if (!mfrc522.PICC_ReadCardSerial())
---

>   //== detect card placement/removal for play/pause function
>   // extend functionality of MFRC522::PICC_IsNewCardPresent() by handling the removal and placement of the same card to invoke pause/play functions
>   rfid_tag_present_prev = rfid_tag_present;
>   
>   _rfid_error_counter += 1;
>   if(_rfid_error_counter > 2){
>     _tag_found = false;
>   }

>   if ((millis() - lastPlacementTime) > placementDelay) {
>     placementTimeout = true;
>   }

>   // Detect Tag without looking for collisions
>   byte bufferATQA[2];
>   byte bufferSize = sizeof(bufferATQA);
>   
>   // Reset baud rates
>   mfrc522.PCD_WriteRegister(mfrc522.TxModeReg, 0x00);
>   mfrc522.PCD_WriteRegister(mfrc522.RxModeReg, 0x00);
>   // Reset ModWidthReg
>   mfrc522.PCD_WriteRegister(mfrc522.ModWidthReg, 0x26);
>   
>   MFRC522::StatusCode result = mfrc522.PICC_RequestA(bufferATQA, &bufferSize);

>   if (result == mfrc522.STATUS_OK){
>     if (!mfrc522.PICC_ReadCardSerial()) {
>       Serial.println("ERROR: failed to read from RFID card");
1098a1178,1212
>     }
>     //tag was placed and its serial was successfully read, continue
>     _rfid_error_counter = 0;
>     _tag_found = true;
>   }
>   
>   rfid_tag_present = _tag_found;
>   
>   //-- rising edge -----
>   if (rfid_tag_present && !rfid_tag_present_prev) {
>     Serial.println("Tag found");
>     /*dump_byte_array(mfrc522.uid.uidByte, mfrc522.uid.size);
>     Serial.println();
>     Serial.println("Previous tag");
>     dump_byte_array(uidByte_prev, mfrc522.uid.size);
>     Serial.println();*/
>   
>     //compare first 4 bytes of previous and present uid to check if previous and current uid are identical
>     //note: the uid may store up to 10 bytes, but these do not seem to be used at this time. --Aug 15, 2020
>     if ( (uidByte_prev[0] == mfrc522.uid.uidByte[0])
>       && (uidByte_prev[1] == mfrc522.uid.uidByte[1])
>       && (uidByte_prev[2] == mfrc522.uid.uidByte[2])
>       && (uidByte_prev[3] == mfrc522.uid.uidByte[3]) 
>       && !(((millis() - lastPlacementTime) < placementDelay) && !placementTimeout) ) {
>       Serial.println("...same tag as before --> Resume");
>       if (knownCard) {
>         mp3.start();
>         disablestandbyTimer();
>         //reset placement timer and timeout
>         lastPlacementTime = millis();
>         placementTimeout = false;
>       }
>     } else {
>       Serial.println("...different tag than before --> store uid of RFID tag for identification at a later time and invoke Tonuino-code for new card");
>       memcpy(&uidByte_prev, &mfrc522.uid.uidByte, mfrc522.uid.size);
1101a1216
>           //play folder
1102a1218
>           first_checkin = true;
1105c1221
<     // Neue Karte konfigurieren
---
>         //configure new card, i.e. offer to assign folder and mode to the new tag
1112a1229
>       //old connection needs to be closed to make tag available for future access
1114a1232,1252
>     }
>   //-- falling edge -----
>   } else if (!rfid_tag_present && rfid_tag_present_prev) {
>     Serial.println("Tag gone --> Pause");
>     if (isPlaying() && !first_checkin) {
>       mp3.pause();
>       setstandbyTimer();
>     }
>   }

>   //First tag detection reads data and has to halt tag. This causes a false-positive tag removal.
>   //Workaround for detection of user actually taking the tag off.
>   if (first_checkin) {
>     result = mfrc522.PICC_WakeupA(bufferATQA, &bufferSize);
>     if (result == MFRC522::STATUS_TIMEOUT) {
>       Serial.println("Tag gone (after first check-in) --> Pause");
>       mp3.pause();
>       setstandbyTimer();
>       first_checkin = false;
>     }
>   }