If and while statements not working The second and third &quot;while and &quot;if&quot; are not working but first &quot;While&quot; and &quot;if&quot; does work.. Am I doing something wrong?
#include &lt;DFMiniMp3.h&gt; 

int sw1 = 3;
int sw2 = 4;
int sw3 = 5;

class Mp3Notify
{
  public:
    static void OnError(uint16_t errorCode)
    {
      // see DfMp3_Error for code meaning
      Serial.println();
      Serial.print(&quot;Com Error &quot;);
      Serial.println(errorCode);
    }

    static void OnPlayFinished(uint16_t globalTrack)
    {
      Serial.println();
      Serial.print(&quot;Play finished for #&quot;);
      Serial.println(globalTrack);
    }

    static void OnCardOnline(uint16_t code)
    {
      Serial.println();
      Serial.print(&quot;Card online &quot;);
      Serial.println(code);
    }

    static void OnCardInserted(uint16_t code)
    {
      Serial.println();
      Serial.print(&quot;Card inserted &quot;);
      Serial.println(code);
    }

    static void OnCardRemoved(uint16_t code)
    {
      Serial.println();
      Serial.print(&quot;Card removed &quot;);
      Serial.println(code);
    }
};
DFMiniMp3&lt;HardwareSerial, Mp3Notify&gt; mp3(Serial); //Create the UART connection to the module

void setup()
{

  //3 push buttons with pullups
  pinMode(sw1, INPUT); //Define each button as input with pullup
  pinMode(sw2, INPUT);
  pinMode(sw3, INPUT);

  digitalWrite (sw1, HIGH); //12 Votls supply set to off state
  digitalWrite (sw2, HIGH); //5 Votls supply set to off state
  digitalWrite (sw3, HIGH); //3 Votls supply set to off state

  Serial.begin(9600);
  mp3.begin(); //Start communication with the DFplayer module
  uint16_t volume = mp3.getVolume(); //Get actual volume
  mp3.setVolume(30); //Set new volum (max is 30)
  uint16_t count = mp3.getTotalTrackCount(); //Get the total tracks on the SD card in case we want to sue this later...
}

//just a fucntion that we use to create delays in &quot;ms&quot;
//without using the delay() function
void waitMilliseconds(uint16_t msWait)
{
  uint32_t start = millis();

  while ((millis() - start) &lt; msWait)
  {
    // calling mp3.loop() periodically allows for notifications
    // to be handled without interrupts
    mp3.loop();
    delay(1);
  }
}

void loop()
{

  if (digitalRead(sw1) == LOW)
  {
    mp3.playMp3FolderTrack(1); // Play audio track 0001
    waitMilliseconds(5000); // 1s of delay
    while (digitalRead(sw1) == HIGH); // do nothing until state changes

  }

  if (digitalRead(sw2) == LOW)
  {
    mp3.playMp3FolderTrack(2); // Play audio track 0002
    waitMilliseconds(5000); // 1s of delay

    while (digitalRead(sw2) == HIGH); // do nothing until state changes

  }

  if (digitalRead(sw3) == LOW)
  {
    mp3.playMp3FolderTrack(3); // Play audio track 0002
    waitMilliseconds(5000); // 1s of delay

    while (digitalRead(sw3) == HIGH); // do nothing until state changes
  }


}
After pressing sw1, the first if works. After releasing sw1 (it's a pushbutton), the line while (digitalRead(sw1) == HIGH); will make the code just sit there forever without continuing with the rest of the code until you press sw1 again, which will be caught by the first if unless you release 'sw1' inhumanly fast.
So, once you have pressed and released sw1, the rest of the code with the next two ifs will never run.