Looping

G’day all. I am very basic at programming and I would like some direction. The jest of what I am trying to do is play random audio files from sd card by pushes from 4 separate buttons. Each button representing a period in time of music, Classic, Baroque, Contemporary, Baroque. Button 1 pushed it will play a random file from sd card, push it again and another random file is played. Button 2, 3, 4 same but for other periods of music. Playing the files is not the issue, I believe it is the switch commands I am trying to use, or lack of understanding of brackets?? As of now when I start the arduino (reset) it will loop through the songs on the sd card, starting with baroque, alternating to classic then baroque then classic etc… I have only written code for 1 and 2 buttons so far so it would be easy to troubleshoot. If I comment out the whole button 2 and just keep button 1 in it works great, but not when I uncomment the button 2 stuff. ANy help would be greatly appreciated.

#include <SoftwareSerial.h>
#include <SerialLCD.h>
#include <SD.h>  
#include <TMRpcm.h> 
#include <SPI.h>

#define SD_ChipSelectPin 10
#define DEBOUNCE 5  // button debouncer

TMRpcm tmrpcm;  // create an object for use in this sketch

unsigned long time = 0;

SerialLCD slcd(7,8);   // assign LCD pins

const int buttonPin1 = 1;   // the number of the Arduino pin that button is connected
const int buttonPin2 = 2;
//const int buttonPin3 = 3;
//const int buttonPin4 = 4;

int buttonState1 = 0;       // variable for reading the pushbutton status
int buttonState2 = 0;
//int buttonState3 = 0;
//int buttonState4 = 0;

void setup(){

  tmrpcm.speakerPin = 9; //  Pin that is output for speaker

  pinMode(buttonPin1, INPUT);  // initialize the pushbutton pin as an input:
  pinMode(buttonPin2, INPUT);
  //pinMode(buttonPin3, INPUT);
  //pinMode(buttonPin4, INPUT);
  
  digitalWrite(buttonPin1, LOW);
  digitalWrite(buttonPin2,LOW);

  slcd.begin();  //initialize LCD

  if (!SD.begin(SD_ChipSelectPin)) { // see if the card is present and can be initialized
    slcd.print("CHECK CARD");
    delay(1000);
    slcd.clear();
    return; // don't do anything more if not
  }
  else{
    slcd.print("CARD OK");
    delay(1000);
    slcd.clear();
    delay(1000);

    tmrpcm.play("Pacman.wav");   //the sound file "music" will play each time the arduino powers up, or is reset
    slcd.print("WELCOME PLAYERS");
    delay(4000);
    slcd.clear();
    slcd.setCursor(0,0);
    slcd.print("SELECT PERIOD");
    slcd.setCursor(0,1);
    slcd.print("1, 2, 3, 4");
  }
}

void loop(){
  
buttonState1 = digitalRead(buttonPin1);  // read the state of the pushbutton value
buttonState2 = digitalRead(buttonPin2);

 if (buttonState1 == HIGH) {
  slcd.clear();
  slcd.setCursor(0,0); 
  slcd.print("Baroque");
  
switch (random(1,8)) {
case 1:
   tmrpcm.play("1.WAV");
   delay(8000);
   slcd.setCursor(0,1);
   slcd.print("1.WAV");
   break;
case 2:
   tmrpcm.play("2.WAV");
   delay(6000);
   slcd.setCursor(0,1);
   slcd.print("2.WAV");
   break;
case 3:
   tmrpcm.play("3.WAV");
   delay(11000);
   slcd.setCursor(0,1);
   slcd.print("3.WAV");
   break;
case 4:
   tmrpcm.play("4.WAV");
   delay(8000);
   slcd.setCursor(0,1);
   slcd.print("4.WAV");
   break;
case 5:
   tmrpcm.play("5.WAV");
   delay(14000);
   slcd.setCursor(0,1);
   slcd.print("5.WAV");
   break;
case 6:
   tmrpcm.play("6.WAV");
   delay(15000);
   slcd.setCursor(0,1);
   slcd.print("6.WAV");
   break;
case 7:
   tmrpcm.play("7.WAV");
   delay(10000);
   slcd.setCursor(0,1);
   slcd.print("7.WAV");
   break;
case 8:
   tmrpcm.play("8.WAV");
   delay(12000);
   slcd.setCursor(0,1);
   slcd.print("8.WAV");
   break;
  buttonState1 = buttonState1; 
} 
}else if (buttonState2 == HIGH); {
  slcd.clear();
  slcd.setCursor(0,0); 
  slcd.print("Classic");
  
switch (random(9,20)) {
case 9:
   tmrpcm.play("9.WAV");
   delay(8000);
   slcd.setCursor(0,1);
   slcd.print("9.WAV");
   break;
case 10:
   tmrpcm.play("10.WAV");
   delay(6000);
   slcd.setCursor(0,1);
   slcd.print("10.WAV");
   break;
case 11:
   tmrpcm.play("11.WAV");
   delay(11000);
   slcd.setCursor(0,1);
   slcd.print("11.WAV");
   break;
case 12:
   tmrpcm.play("12.WAV");
   delay(8000);
   slcd.setCursor(0,1);
   slcd.print("12.WAV");
   break;
case 13:
   tmrpcm.play("13.WAV");
   delay(14000);
   slcd.setCursor(0,1);
   slcd.print("13.WAV");
   break;
case 14:
   tmrpcm.play("14.WAV");
   delay(15000);
   slcd.setCursor(0,1);
   slcd.print("14.WAV");
   break;
case 15:
   tmrpcm.play("15.WAV");
   delay(10000);
   slcd.setCursor(0,1);
   slcd.print("15.WAV");
   break;
case 16:
   tmrpcm.play("16.WAV");
   delay(12000);
   slcd.setCursor(0,1);
   slcd.print("16.WAV");
   break;
case 17:
   tmrpcm.play("17.WAV");
   delay(14000);
   slcd.setCursor(0,1);
   slcd.print("17.WAV");
   break;
case 18:
   tmrpcm.play("18.WAV");
   delay(15000);
   slcd.setCursor(0,1);
   slcd.print("18.WAV");
   break;
case 19:
   tmrpcm.play("19.WAV");
   delay(10000);
   slcd.setCursor(0,1);
   slcd.print("19.WAV");
   break;
case 20:
   tmrpcm.play("20.WAV");
   delay(12000);
   slcd.setCursor(0,1);
   slcd.print("20.WAV");
   break;
 buttonState2 = buttonState2;  
  }
 }
}
}else if (buttonState2 == HIGH);

Oops.

Thank you so much for your reply AWOL.if (buttonState2 == HIGH); { I took away else statement and now when I press the 1st button it plays wav random, finishes then kicks right into "classic" song without me pushing the #2 button, then stops playing when song is finished and waits for me to push #1 button again, #2 button not working. Again thanks the push now I feel I am getting closer but still need the experts to lend me the much need push!!!

You got the wrong oops.

Put the else back in, and delete the semicolon.

; http://www.gammon.com.au/forum/?id=12153&page=999#trap13

Thank you Jiggy and Larry info was great to read. Update: I removed semi colon and it worked, but now button 2 does not do anything, any ideas for this one? I will continue reading and sweating

Yea!!!! It now works I forgot to add curly bracket after break: thank you all for the help, I reviewed the doc from Larry, and sure enough it was my code!!

  break;
}  
}else if (buttonState2 == HIGH) {

I was sooo happy up to this point, Everything started working great untill…I added the rest of the songs, the last code I went to only 15 songs on button 2 (9-15) I needed to go to 20. All compiled correctly but there was no intro music or any music when 1 or 2 button was pushed. Correct things (except music being heard) would happen on the LCD, delays, title of music etc…but no sound. So I commented out Case #20 still no sound, then commented out Case #19 then there was sound. I left this commented ot to move further, hoping I could add the 3rd button and 3 cases to test, and the same thing happens, No Music :((. Buttons and all functions work correctly but no sound. I rechecked to make sure speaker and such was good, and it is. I reloaded earlier sketch with less songs to test and that was good. I then reloaded the current sketch and still nuttin…More help would be appreciated once again. And yes I am learning through what guys have responded with. Lots of reading!!! And like previous if I could be steered into the right direction it would be great!!

#include <SoftwareSerial.h>
#include <SerialLCD.h>
#include <SD.h>  
#include <TMRpcm.h> 
#include <SPI.h>

#define SD_ChipSelectPin 10
#define DEBOUNCE 5  // button debouncer

TMRpcm tmrpcm;  // create an object for use in this sketch

unsigned long time = 0;

SerialLCD slcd(7,8);   // assign LCD pins

const int buttonPin1 = 1;   // the number of the Arduino pin that button is connected
const int buttonPin2 = 2;
const int buttonPin3 = 3;
//const int buttonPin4 = 4;

int buttonState1 = 0;       // variable for reading the pushbutton status
int buttonState2 = 0;
int buttonState3 = 0;
//int buttonState4 = 0;

void setup(){

  tmrpcm.speakerPin = 9; //  Pin that is output for speaker

  pinMode(buttonPin1, INPUT);  // initialize the pushbutton pin as an input:
  pinMode(buttonPin2, INPUT);
  pinMode(buttonPin3, INPUT);
  //pinMode(buttonPin4, INPUT);

  slcd.begin();  //initialize LCD

  if (!SD.begin(SD_ChipSelectPin)) { // see if the card is present and can be initialized
    slcd.print("CHECK CARD");
    delay(1000);
    slcd.clear();
    return; // don't do anything more if not
  }
  else{
    slcd.print("CARD OK");
    delay(1000);
    slcd.clear();

    tmrpcm.play("Pacman.wav");   //the sound file "music" will play each time the arduino powers up, or is reset
    slcd.print("WELCOME PLAYERS");
    delay(4000);
    slcd.clear();
    slcd.setCursor(0,0);
    slcd.print("SELECT PERIOD");
    slcd.setCursor(0,1);
    slcd.print("1, 2, 3, 4");
  }
}

void loop(){

  buttonState1 = digitalRead(buttonPin1);  // read the state of the pushbutton value
  buttonState2 = digitalRead(buttonPin2);
  buttonState3 = digitalRead(buttonPin3);

  if (buttonState1 == HIGH) {
    slcd.clear();
    slcd.setCursor(0,0); 
    slcd.print("Baroque");

    switch (random(1,9)) {
    case 1:
      tmrpcm.play("1.WAV");
      delay(8000);
      slcd.clear();
      slcd.setCursor(0,0);
      slcd.print("Bach");
      //slcd.setCursor(0,1);
      //slcd.print("Minuet");
      break;
    case 2:
      tmrpcm.play("2.WAV");
      delay(6000);
      slcd.clear();
      slcd.setCursor(0,0);
      slcd.print("Bach");
      //slcd.setCursor(0,1);
      //slcd.print("Tocatta");
      break;
    case 3:
      tmrpcm.play("3.WAV");
      delay(11000);
      slcd.clear();
      slcd.setCursor(0,0);
      slcd.print("Clarke");
      //slcd.setCursor(0,1);
      //slcd.print("Trumpet Volun");
      break;
    case 4:
      tmrpcm.play("4.WAV");
      delay(8000);
      slcd.clear();
      slcd.setCursor(0,0);
      slcd.print("Handel");
      //slcd.setCursor(0,1);
      //slcd.print("Halleujah");
      break;
    case 5:
      tmrpcm.play("5.WAV");
      delay(14000);
      slcd.clear();
      slcd.setCursor(0,0);
      slcd.print("Handel");
      //slcd.setCursor(0,1);
      //slcd.print("Fireworks");
      break;
    case 6:
      tmrpcm.play("6.WAV");
      delay(15000);
      slcd.clear();
      slcd.setCursor(0,0);
      slcd.print("Handel");
      //slcd.setCursor(0,1);
      //slcd.print("Water");
      break;
    case 7:
      tmrpcm.play("7.WAV");
      delay(10000);
      slcd.clear();
      slcd.setCursor(0,0);
      slcd.print("Vivaldi");
      //slcd.setCursor(0,1);
      //slcd.print("Spring");
      break;
    case 8:
      tmrpcm.play("8.WAV");
      delay(12000);
      slcd.clear();
      slcd.setCursor(0,0);
      slcd.print("Pachebel");
      //slcd.setCursor(0,1);
      //slcd.print("Canon");
      break;
    }
  }  
  else if (buttonState2 == HIGH) {
    slcd.clear();
    slcd.setCursor(0,0); 
    slcd.print("Classic");

    switch (random(9,20)) {
    case 9:
      tmrpcm.play("9.WAV");
      delay(8000);
      slcd.clear();
      slcd.setCursor(0,0);
      slcd.print("Beethoven");
      //slcd.setCursor(0,1);
      //slcd.print("Furelise");
      break;
    case 10:
      tmrpcm.play("10.WAV");
      delay(20000);
      slcd.clear();
      slcd.setCursor(0,0);
      slcd.print("Beethoven");
      //slcd.setCursor(0,1);
      //slcd.print("5th");
      break;
    case 11:
      tmrpcm.play("11.WAV");
      delay(19000);
      slcd.clear();
      slcd.setCursor(0,0);
      slcd.print("Mozart");
      //slcd.setCursor(0,1);
      //slcd.print("Night Music");
      break;
    case 12:
      tmrpcm.play("12.WAV");
      delay(17000);
      slcd.clear();
      slcd.setCursor(0,0);
      slcd.print("Mozart");
      //slcd.setCursor(0,1);
      //slcd.print("Rondo");
      break;
    case 13:
      tmrpcm.play("13.WAV");
      delay(27000);
      slcd.clear();
      slcd.setCursor(0,0);
      slcd.print("Mozart");
      //slcd.setCursor(0,1);
      //slcd.print("Twinkle");
      break;
    case 14:
      tmrpcm.play("14.WAV");
      delay(25000);
      slcd.clear();
      slcd.setCursor(0,0);
      slcd.print("Mozart");
      //slcd.setCursor(0,1);
      //slcd.print("Requiem");
      break;
    case 15:
      tmrpcm.play("15.WAV");
      delay(23000);
      slcd.clear();
      slcd.setCursor(0,0);
      slcd.print("Mozart");
      //slcd.setCursor(0,1);
      //slcd.print("Concerto");
      break;
      case 16:
       tmrpcm.play("16.WAV");
       delay(21000);
       slcd.clear();
       slcd.setCursor(0,1);
       slcd.print("Beethoven");
       break;
       case 17:
       tmrpcm.play("17.WAV");
       delay(18000);
       slcd.clear();
       slcd.setCursor(0,1);
       slcd.print("Haydn");
       break;
       case 18:
       tmrpcm.play("18.WAV");
       delay(41000);
       slcd.clear();
       slcd.setCursor(0,1);
       slcd.print("Schubet");
       break;
       case 19:
       tmrpcm.play("19.WAV");
       delay(17000);
       slcd.clear();
       slcd.setCursor(0,1);
       slcd.print("Boccherini");
       break;
       case 20:
       tmrpcm.play("20.WAV");
       delay(34000);
       slcd.clear();
       slcd.setCursor(0,1);
       slcd.print("Paganini");
       break; 
    }
  }  
  else if (buttonState3 == HIGH) {
    slcd.clear();
    slcd.setCursor(0,0); 
    slcd.print("Romantic");

    switch (random(21,23)) {
    case 21:
      tmrpcm.play("Gersh.WAV");
      delay(2000);
      slcd.clear();
      slcd.setCursor(0,0);
      slcd.print("test21");
      //slcd.setCursor(0,1);
      //slcd.print("Furelise");
      break;
     case 22:
      tmrpcm.play("Pacman.WAV");
      delay(2000);
      slcd.clear();
      slcd.setCursor(0,0);
      slcd.print("test22");
      slcd.setCursor(0,1);
      slcd.print("5th");
      break;
     case 23:
      tmrpcm.play("11.WAV");
      delay(2000);
      slcd.clear();
      slcd.setCursor(0,0);
      slcd.print("test23");
      slcd.setCursor(0,1);
      slcd.print("Night Music");
      break;
    }
  }
}

Don’t think this is your issue, but: Shouldn’t these be 21.wav, 22.wav, 23.wav?

case 21:
tmrpcm.play(“Gersh.WAV”);

case 22:
tmrpcm.play(“Pacman.WAV”);

case 23:
tmrpcm.play(“11.WAV”);

You might consider having the code data-driven - in other words use arrays of filenames and delay values instead of large switch statements.

Crossroads thanks for your reply, I am just using files on the sd card for a test, naming them 21,22,23 should not matter, but I will give it a try anyways.

MarkT would you be able to steer me in the right direction as I really do not have a clue on how to do your suggestion. I've never coded an array and would really appreciate a steer right.

You might want to have a look at this page: http://playground.arduino.cc/Code/AvailableMemory

So I guess I am in great need of help on how to optimize this code??

So I guess I am in great need of help on how to optimize this code??

The strings to be displayed when a song is to be displayed could go in PROGMEM. The names of the songs could, too. The, it's a simple array look-up to get the name of the song and the text to be shown. Way less code.

Thank you Paul for the reply. I guess my biggest problem is knowing where to begin, or how to code it....I have read on arrays, but it is confusing to me. I get what an array does, but I have no idea how to declare it or even where to start, same as "progmem" If I could get you to show me an example I could then get an idea of what I need to do. Sorry for being a noob, but I am truly starting out and this is getting in over my head, but I will keep on pushing fwd. I wouldn't tackle something like this but it's for my daughters school project and I figured it would have been as easy as turning a led off and on!! My hats are off to all you guys here who do this all the time!!!!!!

Again Thank you Paul and everyone else, After long reads and crying I have solved my issue so far. I had to use PROGMEM…here is the code working further that it has to date, and of course a very happy 8 year old girl!!!

#include <SoftwareSerial.h>
#include <SerialLCD.h>
#include <SD.h>  
#include <TMRpcm.h> 
#include <SPI.h>
#include <avr/pgmspace.h>

TMRpcm tmrpcm;  // create an object for use in this sketch
TMRpcm wav;
unsigned long time = 0;

SerialLCD slcd(7,8);   // assign LCD pins
#define SD_ChipSelectPin 10
#define DEBOUNCE 5  // button debouncer

prog_char wav_1[] PROGMEM = "1.wav";
prog_char wav_2[] PROGMEM = "2.wav";
prog_char wav_3[] PROGMEM = "3.wav";
prog_char wav_4[] PROGMEM = "4.wav";
prog_char wav_5[] PROGMEM = "5.wav";
prog_char wav_6[] PROGMEM = "6.wav";
prog_char wav_7[] PROGMEM = "7.wav";
prog_char wav_8[] PROGMEM = "8.wav";
prog_char wav_9[] PROGMEM = "9.wav";
prog_char wav_10[] PROGMEM = "10.wav";
prog_char wav_11[] PROGMEM = "11.wav";
prog_char wav_12[] PROGMEM = "12.wav";
prog_char wav_13[] PROGMEM = "13.wav";
prog_char wav_14[] PROGMEM = "14.wav";
prog_char wav_15[] PROGMEM = "15.wav";
prog_char wav_16[] PROGMEM = "16.wav";
prog_char wav_17[] PROGMEM = "17.wav";
prog_char wav_18[] PROGMEM = "18.wav";
prog_char wav_19[] PROGMEM = "19.wav";
prog_char wav_20[] PROGMEM = "20.wav";
prog_char wav_21[] PROGMEM = "Gersh.wav";

PROGMEM const char *wav_table[] PROGMEM = { 
  wav_1, wav_2, wav_3, wav_4, wav_5, wav_6, wav_7, wav_8, wav_9, wav_10, wav_11, wav_12, wav_13, wav_14, wav_15,  wav_16, wav_17, wav_18,
  wav_19, wav_20, wav_21, };

const int buttonPin1 = 1; 
const int buttonPin2 = 2;
const int buttonPin3 = 3;
const int buttonPin4 = 4;

int buttonState1 = 0; 
int buttonState2 = 0;
int buttonState3 = 0;
//int buttonState4 = 0;

void setup(){

  slcd.begin();  //initialize LCD
  tmrpcm.speakerPin = 9; //  Pin that is output for speaker

  pinMode(buttonPin1, INPUT);  // initialize the pushbutton pin as an input:
  pinMode(buttonPin2, INPUT);
  pinMode(buttonPin3, INPUT);
  pinMode(buttonPin4, INPUT);

  if (!SD.begin(SD_ChipSelectPin)) { // see if the card is present and can be initialized
    slcd.print("CHECK CARD");
    delay(1000);
    slcd.clear();
    return; // don't do anything more if not
  }
  else{
    slcd.print("CARD OK");
    delay(1000);
    slcd.clear();
    tmrpcm.play("Pacman.wav");   //the sound file "music" will play each time the arduino powers up, or is reset
    slcd.print("WELCOME PLAYERS");
    delay(4000);
    slcd.clear();
    slcd.setCursor(0,0);
    slcd.print("SELECT PERIOD");
    slcd.setCursor(0,1);
    slcd.print("1, 2, 3, 4");
  }
}
void loop(){

  buttonState1 = digitalRead(buttonPin1);  // read the state of the pushbutton value
  buttonState2 = digitalRead(buttonPin2);
  buttonState3 = digitalRead(buttonPin3);
  //buttonState4 = digitalRead(buttonPin4);

  if (buttonState1 == HIGH) {
    slcd.clear();
    slcd.setCursor(0,0); 
    slcd.print("Baroque");

    char wavFile[33];
    switch (random(1,8)) {

    case 1: 
      strcpy_P(wavFile, (char*)pgm_read_word(&(wav_table[0])));  //really 1.wav
      wav.play(wavFile);
      delay(8000);
      slcd.setCursor(0,1);
      slcd.print("Bach");
      break;
    case 2: 
      strcpy_P(wavFile, (char*)pgm_read_word(&(wav_table[1])));
      wav.play(wavFile);
      delay(6000);
      slcd.setCursor(0,1);
      slcd.print("Bach");
      break;
    case 3: 
      strcpy_P(wavFile, (char*)pgm_read_word(&(wav_table[2])));
      wav.play(wavFile);
      delay(11000);
      slcd.setCursor(0,1);
      slcd.print("Clarke");
      break;
    case 4: 
      strcpy_P(wavFile, (char*)pgm_read_word(&(wav_table[3])));
      wav.play(wavFile);
      delay(8000);
      slcd.setCursor(0,1);
      slcd.print("Handel");
      break;
    case 5: 
      strcpy_P(wavFile, (char*)pgm_read_word(&(wav_table[4])));
      wav.play(wavFile);
      delay(14000);
      slcd.setCursor(0,1);
      slcd.print("Handel");
      break;
    case 6: 
      strcpy_P(wavFile, (char*)pgm_read_word(&(wav_table[5])));
      wav.play(wavFile);
      delay(15000);
      slcd.setCursor(0,1);
      slcd.print("Handel");
      break;
    case 7: 
      strcpy_P(wavFile, (char*)pgm_read_word(&(wav_table[6])));
      wav.play(wavFile);
      delay(10000);
      slcd.setCursor(0,1);
      slcd.print("Vivaldi");
      break;
    case 8: 
      strcpy_P(wavFile, (char*)pgm_read_word(&(wav_table[7])));
      wav.play(wavFile);
      delay(12000);
      slcd.setCursor(0,1);
      slcd.print("Pachebel");
      break;
    }
  }    
  else if (buttonState2 == HIGH) {
    slcd.clear();
    slcd.setCursor(0,0); 
    slcd.print("Classic");

    char wavFile[33];
    switch (random(9,21)) {

    case 9: 
      strcpy_P(wavFile, (char*)pgm_read_word(&(wav_table[8])));  //really 9.wav
      wav.play(wavFile);
      delay(8000);
      slcd.setCursor(0,1);
      slcd.print("Beethoven");
      break;
    case 10: 
      strcpy_P(wavFile, (char*)pgm_read_word(&(wav_table[9]))); 
      wav.play(wavFile);
      delay(20000);
      slcd.setCursor(0,1);
      slcd.print("Beethoven");
      break;
    case 11: 
      strcpy_P(wavFile, (char*)pgm_read_word(&(wav_table[10]))); 
      wav.play(wavFile);
      delay(19000);
      slcd.setCursor(0,1);
      slcd.print("Mozart");
      break;
    case 12: 
      strcpy_P(wavFile, (char*)pgm_read_word(&(wav_table[11]))); 
      wav.play(wavFile);
      delay(17000);
      slcd.setCursor(0,1);
      slcd.print("Mozart");
      break;
    case 13: 
      strcpy_P(wavFile, (char*)pgm_read_word(&(wav_table[12]))); 
      wav.play(wavFile);
      delay(27000);
      slcd.setCursor(0,1);
      slcd.print("Mozart");
      break;
    case 14: 
      strcpy_P(wavFile, (char*)pgm_read_word(&(wav_table[13]))); 
      wav.play(wavFile);
      delay(25000);
      slcd.setCursor(0,1);
      slcd.print("Mozart");
      break;
    case 15: 
      strcpy_P(wavFile, (char*)pgm_read_word(&(wav_table[14]))); 
      wav.play(wavFile);
      delay(23000);
      slcd.setCursor(0,1);
      slcd.print("Mozart");
      break; 
    case 16: 
      strcpy_P(wavFile, (char*)pgm_read_word(&(wav_table[15]))); //this file needs to be converted to 16khz 8 bit 
      wav.play(wavFile);
      delay(21000);
      slcd.setCursor(0,1);
      slcd.print("Beethoven");
      break;
    case 17: 
      strcpy_P(wavFile, (char*)pgm_read_word(&(wav_table[16]))); 
      wav.play(wavFile);
      delay(18000);
      slcd.setCursor(0,1);
      slcd.print("Haydn");
      break;
    case 18: 
      strcpy_P(wavFile, (char*)pgm_read_word(&(wav_table[17])));    //this file needs to be converted to 16khz 8 bit 
      wav.play(wavFile);
      delay(41000);
      slcd.setCursor(0,1);
      slcd.print("Schubert");
      break;
    case 19: 
      strcpy_P(wavFile, (char*)pgm_read_word(&(wav_table[18]))); //this file needs to be converted to 16khz 8 bit 
      wav.play(wavFile);
      delay(17000);
      slcd.setCursor(0,1);
      slcd.print("Boccherini");
      break;
    case 20: 
      strcpy_P(wavFile, (char*)pgm_read_word(&(wav_table[19])));  //this file needs to be converted to 16khz 8 bit  
      wav.play(wavFile);
      delay(34000);
      slcd.setCursor(0,1);
      slcd.print("Paganini");
      break;
    }
  }  
  else if (buttonState3 == HIGH) {
    slcd.clear();
    slcd.setCursor(0,0); 
    slcd.print("Romantic");

    char wavFile[33];
    switch (random(21,22)) {

    case 21: 
      strcpy_P(wavFile, (char*)pgm_read_word(&(wav_table[20])));  
      wav.play(wavFile);
      delay(8000);
      slcd.setCursor(0,1);
      slcd.print("Gersh");
      break;    
    }
  }
}

but of course now it's doing the same thing after adding more songs, is there another way to have all the songs I need like 15 per category? Cause I can only have 8 per category, I guess this is a memory thing???????

I guess this is a memory thing???????

Is your ? key stuck? Get it fixed.

You've been told how to determine if it is. Quit guessing.

strcpy_P(wavFile, (char*)pgm_read_word(&(wav_table[20])));

Needs more macro.