Low memory available, stability problems may occur.

can you help me to shorten this code to minimize memory availability?

I am working with a Time Alarm for our school that will alarm (1 hr. every MWF) and (1 hr and 30 mins every TTH) with speaking clock every 30 mins. But the output of the sound of the alarm is a tone and the SD card module use as the storage.

I done compiling it but not yet uploaded it to the arduino. when im compiling it, it is okay but "Low memory available, stability problems may occur." appeard.

I am using:

  1. DS1307 RTC module for the clock
  2. Arduino Uno
  3. SD Card Module as the storage.

this is my code:

 #include <TimeAlarms.h>
#include <Time.h>
#include <SD.h>         
#include <SPI.h> 
#define SD_ChipSelectPin 4  
#include <TMRpcm.h>     
#include <Wire.h>  
#include <DS1307RTC.h> 

TMRpcm tmrpcm;

//unsigned long time = 0;

void setup()  {
  // pinMode (2, OUTPUT); 
   Serial.begin(9600);
    while (!Serial) ; 
    setSyncProvider(RTC.get);  
    if(timeStatus()!= timeSet) 
      Serial.println("Unable to sync with the RTC");
    else
     Serial.println("RTC has set the system time");     

                tmrpcm.speakerPin = 9;
 
                 if (!SD.begin(SD_ChipSelectPin)) {  
                 Serial.println("SD fail");  
                return;  
                  }
                tmrpcm.volume(1);
                tmrpcm.play("att.wav"); 
                  
Alarm.alarmRepeat(dowMonday,8,0,0,WeeklyAlarm);
Alarm.alarmRepeat(dowMonday,9,0,0,WeeklyAlarm);
Alarm.alarmRepeat(dowMonday,10,0,0,WeeklyAlarm);
Alarm.alarmRepeat(dowMonday,11,0,0,WeeklyAlarm);
Alarm.alarmRepeat(dowMonday,12,0,0,WeeklyAlarm);
Alarm.alarmRepeat(dowMonday,1,0,0,WeeklyAlarm);
Alarm.alarmRepeat(dowMonday,2,0,0,WeeklyAlarm);
Alarm.alarmRepeat(dowMonday,3,0,0,WeeklyAlarm);
Alarm.alarmRepeat(dowMonday,4,0,0,WeeklyAlarm);
Alarm.alarmRepeat(dowMonday,5,0,0,WeeklyAlarm);
Alarm.alarmRepeat(dowMonday,6,0,0,WeeklyAlarm);

  Alarm.alarmRepeat(dowTuesday,7,30,0,WeeklyAlarm);   
  Alarm.alarmRepeat(dowTuesday,9,0,0,WeeklyAlarm);    
  Alarm.alarmRepeat(dowTuesday,10,30,0,WeeklyAlarm);
  Alarm.alarmRepeat(dowTuesday,12,0,0,WeeklyAlarm);    
  Alarm.alarmRepeat(dowTuesday,13,0,0,WeeklyAlarm);
  Alarm.alarmRepeat(dowTuesday,14,30,0,WeeklyAlarm);    
  Alarm.alarmRepeat(dowTuesday,15,0,0,WeeklyAlarm);    
  Alarm.alarmRepeat(dowTuesday,16,30,0,WeeklyAlarm);    
  Alarm.alarmRepeat(dowTuesday,17,30,0,WeeklyAlarm);    

          Alarm.alarmRepeat(dowWednesday,8,0,0,WeeklyAlarm);   
          Alarm.alarmRepeat(dowWednesday,9,0,0,WeeklyAlarm);  
          Alarm.alarmRepeat(dowWednesday,10,0,0,WeeklyAlarm);   
          Alarm.alarmRepeat(dowWednesday,11,0,0,WeeklyAlarm);   
          Alarm.alarmRepeat(dowWednesday,12,0,0,WeeklyAlarm);   
          Alarm.alarmRepeat(dowWednesday,13,0,0,WeeklyAlarm);   
          Alarm.alarmRepeat(dowWednesday,14,0,0,WeeklyAlarm);   
          Alarm.alarmRepeat(dowWednesday,15,0,0,WeeklyAlarm);   
          Alarm.alarmRepeat(dowWednesday,16,0,0,WeeklyAlarm);   
          Alarm.alarmRepeat(dowWednesday,17,0,0,WeeklyAlarm);   
          Alarm.alarmRepeat(dowWednesday,18,0,0,WeeklyAlarm);   

              Alarm.alarmRepeat(dowThursday,7,30,0,WeeklyAlarm);   
              Alarm.alarmRepeat(dowThursday,9,0,0,WeeklyAlarm);    
              Alarm.alarmRepeat(dowThursday,10,30,0,WeeklyAlarm);
              Alarm.alarmRepeat(dowThursday,12,0,0,WeeklyAlarm);    
              Alarm.alarmRepeat(dowThursday,13,0,0,WeeklyAlarm);
              Alarm.alarmRepeat(dowThursday,14,30,0,WeeklyAlarm);    
              Alarm.alarmRepeat(dowThursday,15,0,0,WeeklyAlarm);    
              Alarm.alarmRepeat(dowThursday,16,30,0,WeeklyAlarm);    
              Alarm.alarmRepeat(dowThursday,17,30,0,WeeklyAlarm);    

                                Alarm.alarmRepeat(dowFriday,8,0,0,WeeklyAlarm);   
                                Alarm.alarmRepeat(dowFriday,9,0,0,WeeklyAlarm);  
                                Alarm.alarmRepeat(dowFriday,10,0,0,WeeklyAlarm);   
                                Alarm.alarmRepeat(dowFriday,11,0,0,WeeklyAlarm);   
                                Alarm.alarmRepeat(dowFriday,12,0,0,WeeklyAlarm);   
                                Alarm.alarmRepeat(dowFriday,13,0,0,WeeklyAlarm);   
                                Alarm.alarmRepeat(dowFriday,14,0,0,WeeklyAlarm);   
                                Alarm.alarmRepeat(dowFriday,15,0,0,WeeklyAlarm);   
                                Alarm.alarmRepeat(dowFriday,16,0,0,WeeklyAlarm);   
                                Alarm.alarmRepeat(dowFriday,17,0,0,WeeklyAlarm);   
                                Alarm.alarmRepeat(dowFriday,18,0,0,WeeklyAlarm);   

Alarm.alarmRepeat(7,30,0,seventhirty);
Alarm.alarmRepeat(8,0,0,eight);
Alarm.alarmRepeat(8,30,0,eightthirty);
Alarm.alarmRepeat(9,0,0,nine);
Alarm.alarmRepeat(9,30,0,ninethirty);
Alarm.alarmRepeat(10,0,0,ten);
Alarm.alarmRepeat(10,30,0,tent);
Alarm.alarmRepeat(11,0,0,eleven);
Alarm.alarmRepeat(11,30,0,elevent);
Alarm.alarmRepeat(12,0,0,twelve);
Alarm.alarmRepeat(13,0,0,one);
Alarm.alarmRepeat(13,30,0,onet);
Alarm.alarmRepeat(14,0,0,two);
Alarm.alarmRepeat(14,30,0,twot);
Alarm.alarmRepeat(15,0,0,three);
Alarm.alarmRepeat(15,30,0,threet);
Alarm.alarmRepeat(16,0,0,four);
Alarm.alarmRepeat(16,30,0,fourt);
Alarm.alarmRepeat(17,0,0,five);
Alarm.alarmRepeat(17,30,0,fivet);
Alarm.alarmRepeat(18,0,0,six);
  }

void loop()
{
  if (timeStatus() == timeSet) {
    digitalClockDisplay();
  } else {
    Serial.println("The time has not been set.  Please run the Time");
    Serial.println("TimeRTCSet example, or DS1307RTC SetTime example.");
    Serial.println();
    delay(4000);
  }
  delay(1000);
  {
    digitalClockDisplay();
    Alarm.delay(1000);
}}

void digitalClockDisplay(){
  Serial.print(hour());
  printDigits(minute());
  printDigits(second());
  Serial.print(" ");
  Serial.print(day());
  Serial.print(" ");
  Serial.print(month());
  Serial.print(" ");
  Serial.print(year()); 
  Serial.println(); 
}

void printDigits(int digits){
  Serial.print(":");
  if(digits < 10)
    Serial.print('0');
  Serial.print(digits);
}
void WeeklyAlarm(){
  tmrpcm.play("open.wav"); }
  
  void seventhirty(){
      tmrpcm.play("730.wav");     }
  
   void eight(){
       tmrpcm.play("8.wav"); }

          void eightthirty(){
             tmrpcm.play("830.wav"); }

          void nine(){
              tmrpcm.play("9.wav"); }

          void ninethirty(){
             tmrpcm.play("930.wav"); }

          void ten(){
             tmrpcm.play("10.wav"); }

          void tent(){
              tmrpcm.play("1030.wav"); }

          void eleven(){
             tmrpcm.play("11.wav"); }   

          void elevent(){
              tmrpcm.play("1130.wav"); }

          void twelve(){
              tmrpcm.play("speak 12.wav"); }

          void one(){
              tmrpcm.play("1.wav"); }

          void onet(){
              tmrpcm.play("130.wav"); }

          void two(){
               tmrpcm.play("2.wav"); }

          void twot(){
                tmrpcm.play("230.wav"); }

          void three(){
                 tmrpcm.play("3.wav"); }

          void threet(){
                tmrpcm.play("330.wav"); }

          void four(){
              tmrpcm.play("4.wav"); }

          void fourt(){
               tmrpcm.play("430.wav"); }

          void five(){
              tmrpcm.play("5.wav"); }

          void fivet(){
               tmrpcm.play("530.wav"); }

          void six(){
              tmrpcm.play("6.wav"); }

thank you and hoping that you can help me with this. More power to all!!!

I'm probably going to regret this!!!

I haven't the hardware to test or an Arduino compatible IDE at hand to even compile this. And since you haven't even posted the compiler output I don't know what memory you're running out tho RAM is most likely.

I don't even have a clue how much RAM is being used to build the list of Alarms.

But I'll throw this at you.

Try moving some of the data and strings to PROGMEM which MAY free up RAM.

I'm more of a PIC32 developer than AVR so I don't always get my PROGMEM usage right without re-experimentation which I can't do at the moment.

// <https://forum.arduino.cc/index.php?topic=365291.0>

#define COUNT_ENTRIES(ARRAY)    (sizeof(ARRAY) / sizeof(ARRAY[0]))

#define SD_ChipSelectPin 4

#include <TimeAlarms.h>
#include <Time.h>
#include <SD.h>
#include <SPI.h>

#include <TMRpcm.h>
#include <Wire.h>
#include <DS1307RTC.h>

struct dhmsf_alarm_entry_t
{
    const timeDayOfWeek_t   day_of_week;
    const int               hour;
    const int               minute;
    const int               second;
    const OnTick_t          handler;
};

struct hmsf_alarm_entry_t
{
    const int               hour;
    const int               minute;
    const int               second;
    const OnTick_t          handler;
};


TMRpcm tmrpcm;

//unsigned long time = 0;

void WeeklyAlarm()      { tmrpcm.play("open.wav");     }

void twelve()           { tmrpcm.play("speak 12.wav"); }
void one()              { tmrpcm.play("1.wav");        }
void onet()             { tmrpcm.play("130.wav");      }
void two()              { tmrpcm.play("2.wav");        }
void twot()             { tmrpcm.play("230.wav");      }
void three()            { tmrpcm.play("3.wav");        }
void threet()           { tmrpcm.play("330.wav");      }
void four()             { tmrpcm.play("4.wav");        }
void fourt()            { tmrpcm.play("430.wav");      }
void five()             { tmrpcm.play("5.wav");        }
void fivet()            { tmrpcm.play("530.wav");      }
void six()              { tmrpcm.play("6.wav");        }
void seventhirty()      { tmrpcm.play("730.wav");      }
void eight()            { tmrpcm.play("8.wav");        }
void eightthirty()      { tmrpcm.play("830.wav");      }
void nine()             { tmrpcm.play("9.wav");        }
void ninethirty()       { tmrpcm.play("930.wav");      }
void ten()              { tmrpcm.play("10.wav");       }
void tent()             { tmrpcm.play("1030.wav");     }
void eleven()           { tmrpcm.play("11.wav");       }
void elevent()          { tmrpcm.play("1130.wav");     }

const struct dhmsf_alarm_entry_t    dhmsf_entries[] PROGMEM =
{
      { dowMonday,     8,  0,  0, WeeklyAlarm }
    , { dowMonday,     9,  0,  0, WeeklyAlarm }
    , { dowMonday,    10,  0,  0, WeeklyAlarm }
    , { dowMonday,    11,  0,  0, WeeklyAlarm }
    , { dowMonday,    12,  0,  0, WeeklyAlarm }
    , { dowMonday,     1,  0,  0, WeeklyAlarm }
    , { dowMonday,     2,  0,  0, WeeklyAlarm }
    , { dowMonday,     3,  0,  0, WeeklyAlarm }
    , { dowMonday,     4,  0,  0, WeeklyAlarm }
    , { dowMonday,     5,  0,  0, WeeklyAlarm }
    , { dowMonday,     6,  0,  0, WeeklyAlarm }

    , { dowTuesday,    7, 30,  0, WeeklyAlarm }
    , { dowTuesday,    9,  0,  0, WeeklyAlarm }
    , { dowTuesday,   10, 30,  0, WeeklyAlarm }
    , { dowTuesday,   12,  0,  0, WeeklyAlarm }
    , { dowTuesday,   13,  0,  0, WeeklyAlarm }
    , { dowTuesday,   14, 30,  0, WeeklyAlarm }
    , { dowTuesday,   15,  0,  0, WeeklyAlarm }
    , { dowTuesday,   16, 30,  0, WeeklyAlarm }
    , { dowTuesday,   17, 30,  0, WeeklyAlarm }

    , { dowWednesday,  8,  0,  0, WeeklyAlarm }
    , { dowWednesday,  9,  0,  0, WeeklyAlarm }
    , { dowWednesday, 10,  0,  0, WeeklyAlarm }
    , { dowWednesday, 11,  0,  0, WeeklyAlarm }
    , { dowWednesday, 12,  0,  0, WeeklyAlarm }
    , { dowWednesday, 13,  0,  0, WeeklyAlarm }
    , { dowWednesday, 14,  0,  0, WeeklyAlarm }
    , { dowWednesday, 15,  0,  0, WeeklyAlarm }
    , { dowWednesday, 16,  0,  0, WeeklyAlarm }
    , { dowWednesday, 17,  0,  0, WeeklyAlarm }
    , { dowWednesday, 18,  0,  0, WeeklyAlarm }

    , { dowThursday,  7, 30,   0, WeeklyAlarm }
    , { dowThursday,  9,  0,   0, WeeklyAlarm }
    , { dowThursday, 10, 30,   0, WeeklyAlarm }
    , { dowThursday, 12,  0,   0, WeeklyAlarm }
    , { dowThursday, 13,  0,   0, WeeklyAlarm }
    , { dowThursday, 14, 30,   0, WeeklyAlarm }
    , { dowThursday, 15,  0,   0, WeeklyAlarm }
    , { dowThursday, 16, 30,   0, WeeklyAlarm }
    , { dowThursday, 17, 30,   0, WeeklyAlarm }

    , { dowFriday,    8,  0,   0, WeeklyAlarm }
    , { dowFriday,    9,  0,   0, WeeklyAlarm }
    , { dowFriday,   10,  0,   0, WeeklyAlarm }
    , { dowFriday,   11,  0,   0, WeeklyAlarm }
    , { dowFriday,   12,  0,   0, WeeklyAlarm }
    , { dowFriday,   13,  0,   0, WeeklyAlarm }
    , { dowFriday,   14,  0,   0, WeeklyAlarm }
    , { dowFriday,   15,  0,   0, WeeklyAlarm }
    , { dowFriday,   16,  0,   0, WeeklyAlarm }
    , { dowFriday,   17,  0,   0, WeeklyAlarm }
    , { dowFriday,   18,  0,   0, WeeklyAlarm }
};

const struct hmsf_alarm_entry_t hmsf_entries[] PROGMEM =
{
      {  7, 30,  0, seventhirty }
    , {  8,  0,  0, eight       }
    , {  8, 30,  0, eightthirty }
    , {  9,  0,  0, nine        }
    , {  9, 30,  0, ninethirty  }
    , { 10,  0,  0, ten         }
    , { 10, 30,  0, tent        }
    , { 11,  0,  0, eleven      }
    , { 11, 30,  0, elevent     }
    , { 12,  0,  0, twelve      }
    , { 13,  0,  0, one         }
    , { 13, 30,  0, onet        }
    , { 14,  0,  0, two         }
    , { 14, 30,  0, twot        }
    , { 15,  0,  0, three       }
    , { 15, 30,  0, threet      }
    , { 16,  0,  0, four        }
    , { 16, 30,  0, fourt       }
    , { 17,  0,  0, five        }
    , { 17, 30,  0, fivet       }
    , { 18,  0,  0, six         }
};

void printDigits(int digits)
{
    Serial.print(F(":"));
    if ( digits < 10 )
    {
        Serial.print('0');
    }

    Serial.print(digits);
}

void digitalClockDisplay()
{
    Serial.print(hour());   printDigits(minute());  printDigits(second());
    Serial.print(F(" "));
    Serial.print(day());    Serial.print(F(" "));   Serial.print(month());
    Serial.print(F(" "));
    Serial.println(year());
}

void loop()
{
    if ( timeStatus() == timeSet )
    {
        digitalClockDisplay();
    }
    else
    {
        Serial.println(F("The time has not been set.  Please run the Time"));
        Serial.println(F("TimeRTCSet example, or DS1307RTC SetTime example."));
        Serial.println();
        delay(4000);
    }

    delay(1000);

    digitalClockDisplay();
    Alarm.delay(1000);
}

void setup()
{
//  pinMode (2, OUTPUT);
    Serial.begin(9600);

    while ( ! Serial )
    {   }

    setSyncProvider(RTC.get);
    if ( timeStatus() != timeSet )
    {
        Serial.println(F("Unable to sync with the RTC"));
    }
    else
    {
        Serial.println(F("RTC has set the system time"));
    }

    tmrpcm.speakerPin = 9;

    if ( ! SD.begin(SD_ChipSelectPin))
    {
        Serial.println(F("SD fail"));

        return;
    }

    tmrpcm.volume(1);
    tmrpcm.play("att.wav");


    for ( size_t i = 0; i < COUNT_ENTRIES(dhmsf_entries); i++ )
    {
        const timeDayOfWeek_t   day_of_week = (int)pgm_read_word(dhmsf_entries[i].day_of_week);
        const int               hour        = (int)pgm_read_word(dhmsf_entries[i].hour);
        const int               minute      = (int)pgm_read_word(dhmsf_entries[i].minute);
        const int               second      = (int)pgm_read_word(dhmsf_entries[i].second);
        const OnTick_t          handler     = (OnTick_t)pgm_read_word(dhmsf_entries[i].handler);

        Alarm.alarmRepeat(day_of_week, hour, minute, second, handler);
    }

    for ( size_t i = 0; i < COUNT_ENTRIES(hmsf_entries); i++ )
    {
        const int               hour        = (int)pgm_read_word(hmsf_entries[i].hour);
        const int               minute      = (int)pgm_read_word(hmsf_entries[i].minute);
        const int               second      = (int)pgm_read_word(hmsf_entries[i].second);
        const OnTick_t          handler     = (OnTick_t)pgm_read_word(hmsf_entries[i].handler);

        Alarm.alarmRepeat(hour, minute, second, handler);
    }
}

thon95:
I am using:

  1. DS1307 RTC module for the clock
  2. Arduino Uno
  3. SD Card Module as the storage.

And you are using a whole bunch of third-party libraries as well as the SD card, which uses lot of memory.

First step in saving RAM with 8-bit Atmega controllers would be, not to print literal strings like that:

Serial.println("RTC has set the system time");

but to use the F-macro instead:

Serial.println(F("RTC has set the system time"));

Search for all print/println commands in your sketch, and if the commands print just a literal text, use the F-macro! In that case the text is not printed from RAM, but from the programs flash memory directly.

actually I already fixed the low memory problem of my code, by putting "F" in every println commands...

but now i have trouble in all wav files in this code but it says done uploading.. the error is this:

C:\Users\thon\Documents\Arduino\fin\fin.ino: In function 'void setup()':

C:\Users\thon\Documents\Arduino\fin\fin.ino:31:38: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

                 tmrpcm.play("att.wav"); 

                                      ^

C:\Users\thon\Documents\Arduino\fin\fin.ino: In function 'void WeeklyAlarm()':

C:\Users\thon\Documents\Arduino\fin\fin.ino:150:25: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

   tmrpcm.play("open.wav"); }

                         ^

C:\Users\thon\Documents\Arduino\fin\fin.ino: In function 'void seventhirty()':

C:\Users\thon\Documents\Arduino\fin\fin.ino:153:28: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

       tmrpcm.play("730.wav");     }

                            ^

C:\Users\thon\Documents\Arduino\fin\fin.ino: In function 'void eight()':

C:\Users\thon\Documents\Arduino\fin\fin.ino:156:27: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

        tmrpcm.play("8.wav"); }

                           ^

C:\Users\thon\Documents\Arduino\fin\fin.ino: In function 'void eightthirty()':

C:\Users\thon\Documents\Arduino\fin\fin.ino:159:35: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

              tmrpcm.play("830.wav"); }

                                   ^

C:\Users\thon\Documents\Arduino\fin\fin.ino: In function 'void nine()':

C:\Users\thon\Documents\Arduino\fin\fin.ino:162:34: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

               tmrpcm.play("9.wav"); }

                                  ^

C:\Users\thon\Documents\Arduino\fin\fin.ino: In function 'void ninethirty()':

C:\Users\thon\Documents\Arduino\fin\fin.ino:165:35: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

              tmrpcm.play("930.wav"); }

                                   ^

C:\Users\thon\Documents\Arduino\fin\fin.ino: In function 'void ten()':

C:\Users\thon\Documents\Arduino\fin\fin.ino:168:34: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

              tmrpcm.play("10.wav"); }

                                  ^

C:\Users\thon\Documents\Arduino\fin\fin.ino: In function 'void tent()':

C:\Users\thon\Documents\Arduino\fin\fin.ino:171:37: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

               tmrpcm.play("1030.wav"); }

                                     ^

C:\Users\thon\Documents\Arduino\fin\fin.ino: In function 'void eleven()':

C:\Users\thon\Documents\Arduino\fin\fin.ino:174:34: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

              tmrpcm.play("11.wav"); }   

                                  ^

C:\Users\thon\Documents\Arduino\fin\fin.ino: In function 'void elevent()':

C:\Users\thon\Documents\Arduino\fin\fin.ino:177:37: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

               tmrpcm.play("1130.wav"); }

                                     ^

C:\Users\thon\Documents\Arduino\fin\fin.ino: In function 'void twelve()':

C:\Users\thon\Documents\Arduino\fin\fin.ino:180:41: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

               tmrpcm.play("speak 12.wav"); }

                                         ^

C:\Users\thon\Documents\Arduino\fin\fin.ino: In function 'void one()':

C:\Users\thon\Documents\Arduino\fin\fin.ino:183:34: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

               tmrpcm.play("1.wav"); }

                                  ^

C:\Users\thon\Documents\Arduino\fin\fin.ino: In function 'void onet()':

C:\Users\thon\Documents\Arduino\fin\fin.ino:186:36: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

               tmrpcm.play("130.wav"); }

                                    ^

C:\Users\thon\Documents\Arduino\fin\fin.ino: In function 'void two()':

C:\Users\thon\Documents\Arduino\fin\fin.ino:189:35: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

                tmrpcm.play("2.wav"); }

                                   ^

C:\Users\thon\Documents\Arduino\fin\fin.ino: In function 'void twot()':

C:\Users\thon\Documents\Arduino\fin\fin.ino:192:38: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

                 tmrpcm.play("230.wav"); }

                                      ^

C:\Users\thon\Documents\Arduino\fin\fin.ino: In function 'void three()':

C:\Users\thon\Documents\Arduino\fin\fin.ino:195:37: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

                  tmrpcm.play("3.wav"); }

                                     ^

C:\Users\thon\Documents\Arduino\fin\fin.ino: In function 'void threet()':

C:\Users\thon\Documents\Arduino\fin\fin.ino:198:38: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

                 tmrpcm.play("330.wav"); }

                                      ^

C:\Users\thon\Documents\Arduino\fin\fin.ino: In function 'void four()':

C:\Users\thon\Documents\Arduino\fin\fin.ino:201:34: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

               tmrpcm.play("4.wav"); }

                                  ^

C:\Users\thon\Documents\Arduino\fin\fin.ino: In function 'void fourt()':

C:\Users\thon\Documents\Arduino\fin\fin.ino:204:37: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

                tmrpcm.play("430.wav"); }

                                     ^

C:\Users\thon\Documents\Arduino\fin\fin.ino: In function 'void five()':

C:\Users\thon\Documents\Arduino\fin\fin.ino:207:34: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

               tmrpcm.play("5.wav"); }

                                  ^

C:\Users\thon\Documents\Arduino\fin\fin.ino: In function 'void fivet()':

C:\Users\thon\Documents\Arduino\fin\fin.ino:210:37: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

                tmrpcm.play("530.wav"); }

                                     ^

C:\Users\thon\Documents\Arduino\fin\fin.ino: In function 'void six()':

C:\Users\thon\Documents\Arduino\fin\fin.ino:213:34: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

               tmrpcm.play("6.wav"); }

                                  ^

what is the meaning of this and can you help me to fix this error

They're only warnings - you should be able to ignore them, or fix with a cast.

thon95:
the error is this:

If your code is not perfect, there are two possibilities: "error" or "warning".

If it is "error", the compiler stops and you have to fix the problem in the code before you can compile it.

If it is "warning", the compiler makes an educated guess about what you have might have thought when writing the code, and continues compiling. If the compiler is right in his assumption, you get the code that you wanted. And if the compiler is wrong, you get a non working software.

In a perfect world you'd replace all code that create "warnings" with modified code, that compiles without creating warnings.

With messages "warning: deprecated" it is often like that:

  • this was allowed in ancient versions of the compiler
  • it works in current versions of the compiler, but creates warnings
  • and in future versions of the compiler it might create errors

So if your code compiles with "warning" messages now, this might happen one day:

  • you upgrade the Arduino-IDE to a new compiler version
  • the new compiler says "error" instead of "warning"

thank you for the information.. I try the old version of the arduino and I compile it without a warning appear . I will try to upload it later .. thank you very much :slight_smile:

thon95:
thank you for the information.. I try the old version of the arduino and I compile it without a warning appear . I will try to upload it later .. thank you very much :slight_smile:

If you just want to disable the warnings in newer versions of Arduino, this is only a setting you can easily switch yourself. Just set:
"File - Preferences - Compiler Warnings: None"

In that case the compiler won't show you warnings in the status window.

But don't believe, that the warnings are gone with that setting, the compiler just won't show them.

jurs:
Search for all print/println commands in your sketch, and if the commands print just a literal text, use the F-macro! In that case the text is not printed from RAM, but from the programs flash memory directly.

I was also receiving a low memory warning. I tried your suggestion and now all is well. Thank you.