Low memory available, mp3 shield and RTC module

hello friends i got a ( Low memory available, stability problems may occur. ) and the code doesnt work i didnt use serial print i use mp3.play

#include <SPI.h>
#include <SdFat.h>
#include <SdFatUtil.h> 
#include <SFEMP3Shield.h>
#include <Wire.h> //include Wire.h library
#include "RTClib.h" 
 RTC_DS3231 rtc ;
SdFat sd;
SFEMP3Shield MP3player;
int x,h,m ;
void setup () { 
pinMode(5, INPUT); 
 Serial.begin(9600); //Begin the Serial at 9600 Baud
 //Print the message if RTC is not available
 if (! rtc.begin()) {
   Serial.println("Couldn't find RTC");
   while (1);
 }
 //Setup of time if RTC lost power or time is not set
 if (rtc.lostPower()) {
   //Sets the code compilation time to RTC DS3231
   rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
 }
 //start the shield
  sd.begin(SD_SEL, SPI_HALF_SPEED);
  MP3player.begin();
}
void loop () {
  x = digitalRead(5);
DateTime now = rtc.now(); 
h = now.hour() ;
 m= now.minute() ;
 if (x ==1 ) 
 {
  MP3player.playMP3 ("Tracksa.mp3") ;
 
  if ( h==00 || h ==12)
 {MP3player.playMP3("Track12");
  
  MP3player.playMP3("Trackw");
  }
  else if (h ==1 || h==13 )
  {MP3player.playMP3("Track1")  ;
  MP3player.playMP3("Trackw");
  }
  else if (h == 2 || h==14 )
  {MP3player.playMP3("Track2");

  MP3player.playMP3("Trackw");
  }
  else if ( h==3 || h==15 ) 
  {MP3player.playMP3("Track3");
 
  MP3player.playMP3("Trackw");
 }
  else if ( h ==4 || h==16 )
  {  MP3player.playMP3("Track4");
 
  MP3player.playMP3("Trackw");
  }
  else if ( h ==5 || h ==17 )
  {   MP3player.playMP3("Track5");
  
  MP3player.playMP3("Trackw");
  } 
  else if ( h==6 || h==18 )
  {MP3player.playMP3("Track6");
  
  MP3player.playMP3("Trackw");
  }
  
  else if ( h == 7 || h== 19 )
  {MP3player.playMP3("Track7");
  
  MP3player.playMP3("Trackw");
  }
  else if ( h ==8 || h == 20) 
  {MP3player.playMP3("Track8");
  
  MP3player.playMP3("Trackw");
  }
  else if ( h== 9 || h == 21 )
  {MP3player.playMP3("Track9");
  
  MP3player.playMP3("Trackw");
  }
 else if ( h ==10 || h ==22 ) 
 {MP3player.playMP3("Track10");
  
MP3player.playMP3("Trackw");
  }
  else if ( h==11 || h == 23 )
  {MP3player.playMP3("Track11");
  
  MP3player.playMP3("Trackw");
 }
  switch (m) 
  {case 1 :
  MP3player.playMP3("Track1.mp3");
 
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
    case 2 :
  MP3player.playMP3("Track2.mp3");
 
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 3 :
  MP3player.playMP3("Track3.mp3");
 
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 4 :
  MP3player.playMP3("Track4.mp3");
 
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 5 :
  MP3player.playMP3("Track5.mp3");
  
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 6 :
  MP3player.playMP3("Track6.mp3");
 
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 7:
  MP3player.playMP3("Track7.mp3");
      ;
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 8 :
  MP3player.playMP3("Track8.mp3");
      ;
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 9 :
  MP3player.playMP3("Track9.mp3");
      ;
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 10 :
  MP3player.playMP3("Track10.mp3");
      ;
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 11 :
  MP3player.playMP3("Track11.mp3");
      ;
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 12 :
  MP3player.playMP3("Track12.mp3");
      ;
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 13 :
  MP3player.playMP3("Track13.mp3");
      ;
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 14 :
  MP3player.playMP3("Track14.mp3");
      ;
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 15 :
  MP3player.playMP3("Track15.mp3");
      ;
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 16 :
  MP3player.playMP3("Track16.mp3");
      ;
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 17 :
  MP3player.playMP3("Track17.mp3");
      ;
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 18 :
  MP3player.playMP3("Track18.mp3");
      ;
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 19 :
  MP3player.playMP3("Track19.mp3");
      ;
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 20 :
  MP3player.playMP3("Track20.mp3");
      ;
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 21 :
  MP3player.playMP3("Track21.mp3");
      ;
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 22 :
  MP3player.playMP3("Track22.mp3");
      ;
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 23 :
  MP3player.playMP3("Track23.mp3");
      ;
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 24 :
  MP3player.playMP3("Track24.mp3");
      ;
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 25 :
  MP3player.playMP3("Track25.mp3");
      ;
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 26 :
  MP3player.playMP3("Track26.mp3");
      ;
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 27 :
  MP3player.playMP3("Track27.mp3");
      ;
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 28 :
  MP3player.playMP3("Track28.mp3");
      ;
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 29 :
  MP3player.playMP3("Track29.mp3");
      ;
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 30 :
  MP3player.playMP3("Track30.mp3");
      ;
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 31 :
  MP3player.playMP3("Track31.mp3");
      ;
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 32 :
  MP3player.playMP3("Track32.mp3");
      ;
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 33 :
  MP3player.playMP3("Track33.mp3");
      ;
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 34 :
  MP3player.playMP3("Track34.mp3");
      ;
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 35 :
  MP3player.playMP3("Track35.mp3");
      ;
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 36 :
  MP3player.playMP3("Track36.mp3");
      ;
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 37 :
  MP3player.playMP3("Track37.mp3");
      ;
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 38 :
  MP3player.playMP3("Track38.mp3");
      ;
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 39 :
  MP3player.playMP3("Track39.mp3");
      
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 40 :
  MP3player.playMP3("Track40.mp3");
      
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 41 :
  MP3player.playMP3("Track41.mp3");
      
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 42 :
  MP3player.playMP3("Track42.mp3");
      
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
   case 43 :
  MP3player.playMP3("Track43.mp3");
      
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 44 :
  MP3player.playMP3("Track44.mp3");
      
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 45 :
  MP3player.playMP3("Track45.mp3");
      
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 46 :
  MP3player.playMP3("Track46.mp3");
      
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
   case 47 :
  MP3player.playMP3("Track47.mp3");
      
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 48 :
  MP3player.playMP3("Track48.mp3");
      
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 49 :
  MP3player.playMP3("Track49.mp3");
      
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 50 :
  MP3player.playMP3("Track50.mp3");
      
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
   case 51 :
  MP3player.playMP3("Track51mp3");
      
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 52 :
  MP3player.playMP3("Track52.mp3");
      
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 53 :
  MP3player.playMP3("Track53.mp3");
      
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 54 :
  MP3player.playMP3("Track54.mp3");
      
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
   
  case 55 :
  MP3player.playMP3("Track55.mp3");
      
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 56 :
  MP3player.playMP3("Track56.mp3");
      
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
   case 57 :
  MP3player.playMP3("Track57.mp3");
     
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 58 :
  MP3player.playMP3("Track58.mp3");
     
  MP3player.playMP3("Trackmin.mp3");
  
  break ;
  case 59 :
  MP3player.playMP3("Track59.mp3");
     
   MP3player.playMP3("Trackmin.mp3");
  
  break ;
  }
 }
}

the problem is the code uses 93% im using arduin uno any solution please ?

You could construct the filename.

(uncompiled and untested)

#include <SPI.h>
#include <SdFat.h>
#include <SdFatUtil.h>
#include <SFEMP3Shield.h>
#include <Wire.h> //include Wire.h library
#include "RTClib.h"
RTC_DS3231 rtc ;
SdFat sd;
SFEMP3Shield MP3player;
int x, h, m ;
void setup () {
  pinMode(5, INPUT);
  Serial.begin(9600); //Begin the Serial at 9600 Baud
  //Print the message if RTC is not available
  if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    while (1);
  }
  //Setup of time if RTC lost power or time is not set
  if (rtc.lostPower()) {
    //Sets the code compilation time to RTC DS3231
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
  }
  //start the shield
  sd.begin(SD_SEL, SPI_HALF_SPEED);
  MP3player.begin();
}

void loop () {
  x = digitalRead(5);
  DateTime now = rtc.now();
  h = now.hour() ;
  m = now.minute() ;
  if (x == 1 ) {
    MP3player.playMP3 ("Tracksa.mp3") ;
    if (h >= 12) {
      h -= 12;
    }
    if (h == 0) {
      h = 12;
    }
    playNumberedHours(h);
    if (m) {
      playNumberedMinutes(m);
    }
  }
}

const char track[] PROGMEM = "Track";

void playNumberedHours(byte number) {
  char holdTrack[8];
  strcpy_P(holdTrack, track);
  byte prefixLen = strlen(holdTrack);
  itoa(number, holdTrack + prefixLen, 10);
  MP3player.playMP3(holdTrack);
  strcpy_P(holdTrack + prefixLen, PSTR("w"));
  MP3player.playMP3(holdTrack);
}

void playNumberedMinutes(byte number) {
  char holdTrack[12];
  strcpy_P(holdTrack, track);
  byte prefixLen = strlen(holdTrack);
  itoa(number, holdTrack + prefixLen, 10);
  strcat_P(holdTrack, PSTR(".mp3"));
  MP3player.playMP3(holdTrack);
  strcpy_P(holdTrack, PSTR("Trackmin.mp3"));
  MP3player.playMP3(holdTrack);
}

Seems to work.

class Tester {
  public:
    void playMP3(char* filename) {
      Serial.write('\'');
      Serial.print(filename);
      Serial.println(F("'"));
    }
} MP3player;

void setup () {
  Serial.begin(250000);
  for (byte h = 0; h < 24; h++) {
    playNumberedHours(h);
  }
  for (byte m = 0; m < 60; m++) {
    playNumberedMinutes(m);
  }
}

void loop () {}

const char track[] PROGMEM = "Track";

void playNumberedHours(byte number) {
  char holdTrack[8];
  strcpy_P(holdTrack, track);
  byte prefixLen = strlen(holdTrack);
  itoa(number, holdTrack + prefixLen, 10);
  MP3player.playMP3(holdTrack);
  strcpy_P(holdTrack + prefixLen, PSTR("w"));
  MP3player.playMP3(holdTrack);
}

void playNumberedMinutes(byte number) {
  char holdTrack[12];
  strcpy_P(holdTrack, track);
  byte prefixLen = strlen(holdTrack);
  itoa(number, holdTrack + prefixLen, 10);
  strcat_P(holdTrack, PSTR(".mp3"));
  MP3player.playMP3(holdTrack);
  strcpy_P(holdTrack, PSTR("Trackmin.mp3"));
  MP3player.playMP3(holdTrack);
}
'Track0'
'Trackw'
'Track1'
'Trackw'
'Track2'
'Trackw'
'Track3'
'Trackw'
'Track4'
'Trackw'
'Track5'
'Trackw'
'Track6'
'Trackw'
'Track7'
'Trackw'
'Track8'
'Trackw'
'Track9'
'Trackw'
'Track10'
'Trackw'
'Track11'
'Trackw'
'Track12'
'Trackw'
'Track13'
'Trackw'
'Track14'
'Trackw'
'Track15'
'Trackw'
'Track16'
'Trackw'
'Track17'
'Trackw'
'Track18'
'Trackw'
'Track19'
'Trackw'
'Track20'
'Trackw'
'Track21'
'Trackw'
'Track22'
'Trackw'
'Track23'
'Trackw'
'Track0.mp3'
'Trackmin.mp3'
'Track1.mp3'
'Trackmin.mp3'
'Track2.mp3'
'Trackmin.mp3'
'Track3.mp3'
'Trackmin.mp3'
'Track4.mp3'
'Trackmin.mp3'
'Track5.mp3'
'Trackmin.mp3'
'Track6.mp3'
'Trackmin.mp3'
'Track7.mp3'
'Trackmin.mp3'
'Track8.mp3'
'Trackmin.mp3'
'Track9.mp3'
'Trackmin.mp3'
'Track10.mp3'
'Trackmin.mp3'
'Track11.mp3'
'Trackmin.mp3'
'Track12.mp3'
'Trackmin.mp3'
'Track13.mp3'
'Trackmin.mp3'
'Track14.mp3'
'Trackmin.mp3'
'Track15.mp3'
'Trackmin.mp3'
'Track16.mp3'
'Trackmin.mp3'
'Track17.mp3'
'Trackmin.mp3'
'Track18.mp3'
'Trackmin.mp3'
'Track19.mp3'
'Trackmin.mp3'
'Track20.mp3'
'Trackmin.mp3'
'Track21.mp3'
'Trackmin.mp3'
'Track22.mp3'
'Trackmin.mp3'
'Track23.mp3'
'Trackmin.mp3'
'Track24.mp3'
'Trackmin.mp3'
'Track25.mp3'
'Trackmin.mp3'
'Track26.mp3'
'Trackmin.mp3'
'Track27.mp3'
'Trackmin.mp3'
'Track28.mp3'
'Trackmin.mp3'
'Track29.mp3'
'Trackmin.mp3'
'Track30.mp3'
'Trackmin.mp3'
'Track31.mp3'
'Trackmin.mp3'
'Track32.mp3'
'Trackmin.mp3'
'Track33.mp3'
'Trackmin.mp3'
'Track34.mp3'
'Trackmin.mp3'
'Track35.mp3'
'Trackmin.mp3'
'Track36.mp3'
'Trackmin.mp3'
'Track37.mp3'
'Trackmin.mp3'
'Track38.mp3'
'Trackmin.mp3'
'Track39.mp3'
'Trackmin.mp3'
'Track40.mp3'
'Trackmin.mp3'
'Track41.mp3'
'Trackmin.mp3'
'Track42.mp3'
'Trackmin.mp3'
'Track43.mp3'
'Trackmin.mp3'
'Track44.mp3'
'Trackmin.mp3'
'Track45.mp3'
'Trackmin.mp3'
'Track46.mp3'
'Trackmin.mp3'
'Track47.mp3'
'Trackmin.mp3'
'Track48.mp3'
'Trackmin.mp3'
'Track49.mp3'
'Trackmin.mp3'
'Track50.mp3'
'Trackmin.mp3'
'Track51.mp3'
'Trackmin.mp3'
'Track52.mp3'
'Trackmin.mp3'
'Track53.mp3'
'Trackmin.mp3'
'Track54.mp3'
'Trackmin.mp3'
'Track55.mp3'
'Trackmin.mp3'
'Track56.mp3'
'Trackmin.mp3'
'Track57.mp3'
'Trackmin.mp3'
'Track58.mp3'
'Trackmin.mp3'
'Track59.mp3'
'Trackmin.mp3'

it didnt work i dont know what is the problem ,,, the idea is when i push a putton it shows me the REAL TIME using RTC module and the mp3 played the files for example

the time now 12:43

input digital =1

mp3 playes ( tracksa.mp3) then (track12.mp3 ) then (trackw.mp3) then (track43.mp3) then plays (trackmi.mp3)

i hope the idea is clear

khaled213:
it didnt work

With that error description you are on your own.

Good luck.