Alarm clock will not play .WAV file off of SD card

Hi,

I am currently working on a project to create an alarm clock, that will play a ".WAV" file off of an SD card.

I am trying to integrate the following components on an Genuino Uno:
-DS 1307 RTC
-SD Shield 3.0
-LCD (16, 2) display

The code I have is probably a lot more clunky than I need it to be, but I am new to the Arduino world so at the moment it is the best I can put together. It is splices of different codes found out on the interweb.

The issue I have is that once the program enters into the Alarm function the file will not play off of the SD card. I have placed a "Serial.print" command inside the alarm function, so I know that the program is at least entering the function, but is just not playing the file. The file does play when I have a program to play off the SD card as a stand alone program, so the ability is there. But once everything is combined it will not play.

As the code is long, I have attached it to this post. And portion of the sketch trying to play the audio file is at the bottom of the sketch.

Any assistance at all is much appreciated.

**EDIT - So I changed around some wiring, and changed the code to test a possible solution. I thought the LCD pins 11, 12 were interfering with the SPI pins 11, 12, 13. This did not prove to be the case and actually made the problem worse, as the LCD display would not work properly now. So I changed the wiring back to the original configuration but forgot to change the code back to the original configuration before attaching it to this post. The code in this section below (not the attachment) is the code that I was using before making things worse with the LCD.

#include <RTClib.h>
#include <TimeLib.h>
#include <Wire.h>
#include<EEPROM.h>
#include "TMRpcm.h"
#include "SD.h"
#include "SPI.h"
#define SD_ChipSelectPin 4

#include <LiquidCrystal.h>
LiquidCrystal lcd(2, 6, 8, 9, 11, 12);
RTC_DS1307 RTC;
int temp, inc, hours1, minut, add = 11;
int next = 7;
int INC = 5;
int set_mad = 3;
//#define buzzer 3
int HOUR, MINUT, SECOND;

TMRpcm tmrpcm; //***

void setup()
{
  Serial.begin(9600);
  Wire.begin();
  RTC.begin();
  lcd.begin(16, 2);
  pinMode(INC, INPUT);
  pinMode(next, INPUT);
  pinMode(set_mad, INPUT);
  tmrpcm.speakerPin = 10;

  //pinMode(buzzer, OUTPUT);
  digitalWrite(next, HIGH);
  digitalWrite(set_mad, HIGH);
  digitalWrite(INC, HIGH);

  lcd.setCursor(0, 0);
  lcd.print("Arduino Project");
  lcd.setCursor(0, 1);
  lcd.print("Alarm Clock ");
  delay(2000);

  if (!RTC.isrunning())
  {
    RTC.adjust(DateTime(__DATE__, __TIME__));
  }
}

void loop()
{
  int temp = 0, val = 1, temp4;
  DateTime now = RTC.now();
  if (digitalRead(set_mad) == 0)     //set Alarm time
  {
    lcd.setCursor(0, 0);
    lcd.print("  Set Alarm  ");
    delay(2000);
    defualt();
    time();
    delay(1000);
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("  Alarm time ");
    lcd.setCursor(0, 1);
    lcd.print(" has been set  ");
    delay(2000);
  }
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Time:");
  lcd.setCursor(6, 0);
  lcd.print(HOUR = now.hour(), DEC);
  lcd.print(":");
  lcd.print(MINUT = now.minute(), DEC);
  lcd.print(":");
  lcd.print(SECOND = now.second(), DEC);
  lcd.setCursor(0, 1);
  lcd.print("Date: ");
  lcd.print(now.day(), DEC);
  lcd.print("/");
  lcd.print(now.month(), DEC);
  lcd.print("/");
  lcd.print(now.year(), DEC);
  match();
  delay(200);
}
void defualt()
{
  lcd.setCursor(0, 1);
  lcd.print(HOUR);
  lcd.print(":");
  lcd.print(MINUT);
  lcd.print(":");
  lcd.print(SECOND);
}

void time()            //Function to set alarm time and feed time into Internal eeprom
{
  int temp = 1, minuts = 0, hours = 0, seconds = 0;
  while (temp == 1)
  {
    if (digitalRead(INC) == 0)
    {
      HOUR++;
      if (HOUR == 24)
      {
        HOUR = 0;
      }
      while (digitalRead(INC) == 0);
    }
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Set Alarm Time ");
    //lcd.print(x);
    lcd.setCursor(0, 1);
    lcd.print(HOUR);
    lcd.print(":");
    lcd.print(MINUT);
    lcd.print(":");
    lcd.print(SECOND);
    delay(100);
    if (digitalRead(next) == 0)
    {
      hours1 = HOUR;
      EEPROM.write(add++, hours1);
      temp = 2;
      while (digitalRead(next) == 0);
    }
  }

  while (temp == 2)
  {
    if (digitalRead(INC) == 0)
    {
      MINUT++;
      if (MINUT == 60)
      {
        MINUT = 0;
      }
      while (digitalRead(INC) == 0);
    }
    // lcd.clear();
    lcd.setCursor(0, 1);
    lcd.print(HOUR);
    lcd.print(":");
    lcd.print(MINUT);
    lcd.print(":");
    lcd.print(SECOND);
    delay(100);
    if (digitalRead(next) == 0)
    {
      minut = MINUT;
      EEPROM.write(add++, minut);
      temp = 0;
      while (digitalRead(next) == 0);
    }
  }
  delay(1000);
}

void match()                 //Checking for a match in alarm time and real time
{
  int tem[17];
  for (int i = 11; i < 17; i++)
  {
    tem[i] = EEPROM.read(i);
  }
  if (HOUR == tem[11] && MINUT == tem[12])
  {
    beep();
    //beep();
    //beep();
    //beep();
    lcd.clear();
    lcd.print("Wake Up........");
    lcd.setCursor(0, 1);
    lcd.print("Wake Up.......");
    //beep();
    //beep();
    //beep();
    //beep();
  }
}

void beep()                      //The alarm section trying to play the audio file
{
  Serial.println ("Entered alarm section");
  tmrpcm.setVolume(6);
  tmrpcm.play("The_view.wav");
  //digitalWrite (10, HIGH);
  //delay (500);
  //digitalWrite (10, LOW);
  //delay (500);
}

Alarm_clock_SD_Dec_11.ino (3.67 KB)

I thought the LCD pins 11, 12 were interfering with the SPI pins 11, 12, 13. This did not prove to be the case

Nonsense. Moving stuff may not have solved the problem, but you can NOT have the LCD on the SPI pins.

With the LCD in the drawer, and all the calls to the lcd instance commented out, does the code work?

PaulS:
Nonsense. Moving stuff may not have solved the problem, but you can NOT have the LCD on the SPI pins.

With the LCD in the drawer, and all the calls to the lcd instance commented out, does the code work?

I commented out all of the LCD instances, and replaced them with Serial.print so I could use the Serial monitor to set the alarm. The program went into the alarm function, but did pull the sound file off of the SD card.

tmrpcm.speakerPin = 10;

You are trying to use an SPI pin to output the sound. Try another one.

but did pull the sound file off of the SD card.

In English this should be said as:-
but did pull the sound file off the SD card.

Grumpy_Mike:
In English this should be said as:-
but did pull the sound file off the SD card.

I meant to type 'did not* pull the sound file off /* of */ the SD card'
My apologies.

I tried pin 9.
The program entered the alarm function but did again did not pull the sound file off the SD card.
In the serial monitor, it prints "Entered alarm section" multiple times, with next two no delay, it seems to be skipping right over the command:

tmrpcm.setVolume(6);
tmrpcm.play("The_view.wav");

NDSundin:
The program entered the alarm function but /did/ again did not

It seems my grammar has taken the day off today.

What I would do is to go and run the basic example in the TMRpcm libiary and see if you can get any sound out of it. That will rule out it being a problem with the sound file or SD card interface.

I have done that.

The following example does play a sound file. You'll notice that I have pin 10 as the speakerpin again. The original example uses pin 9. But After playing around with it I found that pin 9 would not work. Tried pin 10, and I was able to play the sound file.

#include "SD.h"
#define SD_ChipSelectPin 4
#include "TMRpcm.h"
#include "SPI.h"

TMRpcm tmrpcm;

void setup(){
tmrpcm.speakerPin = 10;
Serial.begin(9600);
if (!SD.begin(SD_ChipSelectPin)) {
Serial.println("SD fail");
return;
}

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

void loop(){ }

The original example uses pin 9. But After playing around with it I found that pin 9 would not work. Tried pin 10, and I was able to play the sound file.

That is odd, either pin should work. Are you sure that you have not damaged pin 9?

This page SPI - Arduino Reference tells you that pin 10 must always be set to be an output.

When you try this example have you got nothing else connected to this pin?

So I took everything apart, put it back together, and Pin 9 does work. Both pins seems to work interchangeably. So it just must have been a matter of me not having something hooked up properly the first time. The audio quality seems to be equal between the two pins as well.

NDSundin:
This page SPI - Arduino Reference tells you that pin 10 must always be set to be an output.

When you try this example have you got nothing else connected to this pin?

That is correct, there was nothing else connected to that pin.

I read through the link you had posted. Is there a chance there the CLK that is used with the SPI library, and the DS1307 RTC library I am using are conflicting with one another when I try to read a file off the SD card?

No. The DS1307 device is an I2C device. Pins on the opposite side of the board.

Now, add ONE piece of hardware back, with NO code. Try the example again. If it works, add some code to initialize the device but do NOTHING else with it. If that works, add the code to deal with that device. STOP when things go pear-shaped, and let us know that last thing you did to make them go pear-shaped.

OK,

So I did as you said, putting one piece of hardware in, and then testing to see if the file would play off the SD card.

I got everything set up into the sketch and the file would play properly if I had it set to play while in the "void setup()" function.

I also changed the pins for the LCD display to LiquidCrystal lcd(3, 5, 6, 7, 8, 9);

And I changed my buttons to the following:

int temp, inc, hours1, minut, add = 11;
int next = 0;
int INC = 1;
int set_mad = 2;
int HOUR, MINUT, SECOND;

The SD file played properly, and the text would light up on the LCD.

Next I commented out the SD file that was in the Void Setup() and tried to set the alarm on the clock to see if the file would play inside the alarm function. When I did this though, things started to get a bit hairy.

I got into the setting the alarm function, and could change the hours, but when I hit the "NEXT" button, the lcd display went haywire. Is this because the next button is tied to a PWM pin 0?

I tried to put in a small delay of 1 millisecond to see if I could avoid that. Still didn't really help.

Next I tried the same sketch but I used the serial monitor instead, and the alarm actually worked, sort of. It would Serial.print ("Entered alarm") to the serial monitor a bunch of times, and then if I hit one of the buttons the file would start to play.

I hope this is a clear enough explanation.

Your code does not have a "Void setup". It has a setup() FUNCTION.

You have some code now that only you can see, but you want us to divine why it isn't working. Not going to happen.

My apologies,

Here is the code.

#include "SD.h"
#define SD_ChipSelectPin 4
#include "TMRpcm.h"
#include "SPI.h"
#include <RTClib.h>
#include <Wire.h>
#include <LiquidCrystal.h>
#include <EEPROM.h>
#include <TimeLib.h>

TMRpcm tmrpcm;
RTC_DS1307 RTC;
LiquidCrystal lcd(3, 5, 6, 7, 8, 9);

int temp, inc, hours1, minut, add = 11;
int next = 0;
int INC = 1;
int set_mad = 2;
int HOUR, MINUT, SECOND;

void setup() {

  Wire.begin();
  RTC.begin();
  lcd.begin(16, 2);
  //lcd.print("hello world");
  tmrpcm.speakerPin = 10;
  Serial.begin(9600);

  pinMode(INC, INPUT);
  pinMode(next, INPUT);
  pinMode(set_mad, INPUT);
  digitalWrite(INC, HIGH);
  digitalWrite(next, HIGH);
  digitalWrite(set_mad, HIGH);

  if (!SD.begin(SD_ChipSelectPin)) {
    Serial.println("SD fail");
    return;
  }
  if (!RTC.isrunning())
  {
    RTC.adjust(DateTime(__DATE__, __TIME__));
  }
  lcd.setCursor(0, 0);
  lcd.print("Arduino Project");
  lcd.setCursor(0, 1);
  lcd.print("Alarm Clock ");
  delay(2000);

  //tmrpcm.setVolume(6);
  //tmrpcm.play("The_view.wav");
}

void loop()
{
  int temp = 0, val = 1, temp4;
  DateTime now = RTC.now();
  if (digitalRead(set_mad) == 0)     //set Alarm time
  {
    /*  Serial.print("  Set Alarm  ");
      delay(2000);
      defualt();
      time();
      delay(1000);
      Serial.println("  Alarm time ");
      //lcd.setCursor(0, 1);
      Serial.print(" has been set  ");*/
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("  Set Alarm  ");
    delay(2000);
    defualt();
    time();
    delay(1000);
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("  Alarm time ");
    lcd.setCursor(0, 1);
    lcd.print(" has been set  ");
    delay(2000);
  }

  /*Serial.print("Time:");
    Serial.print(HOUR = now.hour(), DEC);
    Serial.print(":");
    Serial.print(MINUT = now.minute(), DEC);
    Serial.print(":");
    Serial.println(SECOND = now.second(), DEC);*/
  /*Serial.print("Date: ");
    Serial.print(now.day(), DEC);
    Serial.print("/");
    Serial.print(now.month(), DEC);
    Serial.print("/");
    Serial.print(now.year(), DEC);*/
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Time:");
  lcd.setCursor(6, 0);
  lcd.print(HOUR = now.hour(), DEC);
  lcd.print(":");
  lcd.print(MINUT = now.minute(), DEC);
  lcd.print(":");
  lcd.print(SECOND = now.second(), DEC);
  lcd.setCursor(0, 1);
  lcd.print("Date: ");
  lcd.print(now.day(), DEC);
  lcd.print("/");
  lcd.print(now.month(), DEC);
  lcd.print("/");
  lcd.print(now.year(), DEC); * /
  match();
  delay(200);
}
void defualt()
{
  /*Serial.print(HOUR);
    Serial.print(":");
    Serial.print(MINUT);
    Serial.print(":");
    Serial.print(SECOND);*/
  lcd.setCursor(0, 1);
  lcd.print(HOUR);
  lcd.print(":");
  lcd.print(MINUT);
  lcd.print(":");
  lcd.print(SECOND);
}
/*Function to set alarm time and feed time into Internal eeprom*/
void time()
{
  int temp = 1, minuts = 0, hours = 0, seconds = 0;
  while (temp == 1)
  {
    if (digitalRead(INC) == 0)
    {
      HOUR++;
      if (HOUR == 24)
      {
        HOUR = 0;
      }
      while (digitalRead(INC) == 0);
    }
    /*Serial.println("Set Alarm Time ");
      //lcd.print(x);
      //lcd.setCursor(0, 1);
      Serial.print(HOUR);
      Serial.print(":");
      Serial.print(MINUT);
      Serial.print(":");
      Serial.println(SECOND);*/
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Set Alarm Time ");
    //lcd.print(x);
    lcd.setCursor(0, 1);
    lcd.print(HOUR);
    lcd.print(":");
    lcd.print(MINUT);
    lcd.print(":");
    lcd.print(SECOND);
    delay(100);
    if (digitalRead(next) == 0)
      delay(1);
    {
      hours1 = HOUR;
      EEPROM.write(add++, hours1);
      temp = 2;
      while (digitalRead(next) == 0);
    }
  }

  while (temp == 2)
  {
    if (digitalRead(INC) == 0)
    {
      MINUT++;
      if (MINUT == 60)
      {
        MINUT = 0;
      }
      while (digitalRead(INC) == 0);
    }
    /* Serial.print(HOUR);
      Serial.print(":");
      Serial.print(MINUT);
      Serial.print(":");
      Serial.println(SECOND);*/
    lcd.clear();
    lcd.setCursor(0, 1);
    lcd.print(HOUR);
    lcd.print(":");
    lcd.print(MINUT);
    lcd.print(":");
    lcd.print(SECOND);
    delay(100); * /
    if (digitalRead(next) == 0)
      delay(1);
    {
      minut = MINUT;
      EEPROM.write(add++, minut);
      temp = 0;
      while (digitalRead(next) == 0);
    }
  }
  delay(1000);
}
/* Function to chack medication time */
void match()
{
  int tem[17];
  for (int i = 11; i < 17; i++)
  {
    tem[i] = EEPROM.read(i);
  }
  if (HOUR == tem[11] && MINUT == tem[12])
  {
    beep();
    /*Serial.println("Wake Up........");
      //lcd.setCursor(0, 1);
      Serial.println("Wake Up.......");
       //beep();
       //beep();
       //beep();*/
    lcd.clear();
    lcd.print("Wake Up........");
    lcd.setCursor(0, 1);
    lcd.print("Wake Up.......");
    /*//beep();
      //beep();
      //beep();
      //beep();*/
  }
}
/* function to buzzer indication */
void beep()
{
  Serial.println ("Entered alarm section");
  tmrpcm.setVolume(6);
  tmrpcm.play("The_view.wav");
  //digitalWrite (10, HIGH);
  //delay (500);
  //digitalWrite (10, LOW);
  //delay (500);
}

You know, I do believe that I said develop the code bit by bit. The first bit should have had some include statements, some (possibly zero) global variables, a setup() function that initialized the music player and called the play() function, and an empty loop() function.

If that worked, you were to add the LCD hardware with no software. Then, add the LCD initialization code. Adding code bit by bit allows you to mark the block of code that was added, so we could see exactly what made the code/hardware go pear-shaped.

You've got a shit-load of code that has nothing to do with the minimal playing of a song with all the hardware connected.

Try again.

Ok, I have shortened the code up and tested along the way. This code works with all of the hardware connected, but just setting up and printing a simple message on the LCD display, initializing the other hardware, and it does play the file off the SD card with an empty loop().

I have also got to a point where I can display the time on the LCD display, manually enter an alarm time into the void loop () using the IDE. I will post that code in a different post so to try and not get too jumbled up.

#include "SD.h"
#define SD_ChipSelectPin 4
#include "TMRpcm.h"
#include "SPI.h"
#include <RTClib.h>
#include <Wire.h>
#include <LiquidCrystal.h>
#include <EEPROM.h>
#include <TimeLib.h>

TMRpcm tmrpcm;
RTC_DS1307 RTC;
LiquidCrystal lcd(3, 5, 6, 7, 8, 9);

int temp, inc, hours1, minut, add = 11;
int next = 0;
int INC = 1;
int set_mad = 2;
int HOUR, MINUT, SECOND;

void setup() {

  Wire.begin();
  RTC.begin();
  lcd.begin(16, 2);
  lcd.print("hello world");
  tmrpcm.speakerPin = 10;
  Serial.begin(9600);

  pinMode(INC, INPUT);
  pinMode(next, INPUT);
  pinMode(set_mad, INPUT);
  digitalWrite(INC, HIGH);
  digitalWrite(next, HIGH);
  digitalWrite(set_mad, HIGH);

  if (!SD.begin(SD_ChipSelectPin)) {
    Serial.println("SD fail");
    return;
  }
  if (!RTC.isrunning())
  {
    RTC.adjust(DateTime(__DATE__, __TIME__));
  }
  lcd.setCursor(0, 0);
  lcd.print("Arduino Project");
  lcd.setCursor(0, 1);
  lcd.print("Alarm Clock ");
  delay(2000);

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

void loop()
{}

This particular part of the code contains the manually entered alarm time that enters into the play(). I had to add a "SECOND" variable delay of one second before entering into the play()

The issue I am running into now, and I will post shortly is that the LCD display is going squirrelly when I add any pushbuttons into the mix and try to set the alarm without

I am posting this in hopes that this is closer to what you are looking for, as a more simple sketch designed to basically just play the file off the SD card.

#include "SD.h"
#define SD_ChipSelectPin 4
#include "TMRpcm.h"
#include "SPI.h"
#include <RTClib.h>
#include <Wire.h>
#include <LiquidCrystal.h>
#include <EEPROM.h>
#include <TimeLib.h>

TMRpcm tmrpcm;
RTC_DS1307 RTC;
LiquidCrystal lcd(3, 5, 6, 7, 8, 9);

int temp, inc, hours1, minut, add = 11;
int next = 0;
int INC = 1;
int set_mode = 2;
int HOUR, MINUT, SECOND;

void setup() {

  Wire.begin();
  RTC.begin();
  lcd.begin(16, 2);
  //lcd.print("hello world");
  tmrpcm.speakerPin = 10;
  Serial.begin(9600);

  pinMode(INC, INPUT);
  pinMode(next, INPUT);
  pinMode(set_mode, INPUT);
  digitalWrite(INC, HIGH);
  digitalWrite(next, HIGH);
  digitalWrite(set_mode, HIGH);

  if (!SD.begin(SD_ChipSelectPin)) {
    Serial.println("SD fail");
    return;
  }
  if (!RTC.isrunning())
  {
    RTC.adjust(DateTime(__DATE__, __TIME__));
  }
  lcd.setCursor(0, 0);
  lcd.print("Arduino Project");
  lcd.setCursor(0, 1);
  lcd.print("Alarm Clock ");
  delay(2000);
//This will play out of the setup() with all hardware connected and an empty loop()
//This will play out of the setup() with all hardware connected and all of the original code
//I've commented this out and placed it in a play function
  //tmrpcm.setVolume(6);       
  //tmrpcm.play("The_view.wav");
}

void loop()
{
  int temp = 0, val = 1, temp4;
  DateTime now = RTC.now();
  if (digitalRead(set_mode) == 0)     //set Alarm time
  {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("  Set Alarm  ");
    delay(2000);
    defualt();
    //time();
    delay(1000);
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("  Alarm time ");
    lcd.setCursor(0, 1);
    lcd.print(" has been set  ");
    delay(2000);
  }

  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Time:");
  lcd.setCursor(6, 0);
  lcd.print(HOUR = now.hour(), DEC);
  lcd.print(":");
  lcd.print(MINUT = now.minute(), DEC);
  lcd.print(":");
  lcd.print(SECOND = now.second(), DEC);
  lcd.setCursor(0, 1);
  lcd.print("Date: ");
  lcd.print(now.day(), DEC);
  lcd.print("/");
  lcd.print(now.month(), DEC);
  lcd.print("/");
  lcd.print(now.year(), DEC);
  //match();
  delay(200);

// this portion without the "SECOND" variable would enter into the play() but the speaker would chirp
// for one minute, once the minute was up and change to, for this example, 57 the file would then
// start to play. This all took place while the LCD display was still displaying the correct time 
// if (HOUR == 8 && MINUT == 56)
  {
    play();
  }
  
//Manually enter time to set an alarm instead of using push buttons
  //This enters the play() function and plays the file
  //Had to add SECOND, without the code the LCD will still display the time,
  //but the speaker chirps for full minute, will play song when it goes to the next minute
  if (HOUR == 8 && MINUT == 56 && SECOND == 10)
  {
    delay(1000);
    play();
  }
}
void defualt()
{
  lcd.setCursor(0, 1);
  lcd.print(HOUR);
  lcd.print(":");
  lcd.print(MINUT);
  lcd.print(":");
  lcd.print(SECOND);
}

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

Again, I hope this is more of what you were looking for.

This is where I start to run into problems.

I hit a push button (set_mode) to enter the time() to set the alarm
"Set alarm" as well as the time displays, but as soon as I hit any button to increment the hours, or move to the next variable, the LCD display just puts out random characters.

#include "SD.h"
#define SD_ChipSelectPin 4
#include "TMRpcm.h"
#include "SPI.h"
#include <RTClib.h>
#include <Wire.h>
#include <LiquidCrystal.h>
#include <EEPROM.h>
#include <TimeLib.h>

TMRpcm tmrpcm;
RTC_DS1307 RTC;
LiquidCrystal lcd(3, 5, 6, 7, 8, 9);

int temp, inc, hours1, minut, add = 11;
int next = 0;
int INC = 1;
int set_mode = 2;
int HOUR, MINUT, SECOND;

void setup() {

  Wire.begin();
  RTC.begin();
  lcd.begin(16, 2);
  //lcd.print("hello world");
  tmrpcm.speakerPin = 10;
  Serial.begin(9600);

  pinMode(INC, INPUT);
  pinMode(next, INPUT);
  pinMode(set_mode, INPUT);
  digitalWrite(INC, HIGH);
  digitalWrite(next, HIGH);
  digitalWrite(set_mode, HIGH);

  if (!SD.begin(SD_ChipSelectPin)) {
    Serial.println("SD fail");
    return;
  }
  if (!RTC.isrunning())
  {
    RTC.adjust(DateTime(__DATE__, __TIME__));
  }
  lcd.setCursor(0, 0);
  lcd.print("Arduino Project");
  lcd.setCursor(0, 1);
  lcd.print("Alarm Clock ");
  delay(2000);
  //This will play out of the setup() with all hardware connected and an empty loop()
  //This will play out of the setup() with all hardware connected and all of the original code
  //I've commented this out and placed it in a play function
  //tmrpcm.setVolume(6);
  //tmrpcm.play("The_view.wav");
}

void loop()
{
  int temp = 0, val = 1, temp4;
  DateTime now = RTC.now();
  if (digitalRead(set_mode) == 0)     //set Alarm time
  {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("  Set Alarm  ");
    delay(2000);
    defualt();
    //time();
    delay(1000);
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("  Alarm time ");
    lcd.setCursor(0, 1);
    lcd.print(" has been set  ");
    delay(2000);
  }

  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Time:");
  lcd.setCursor(6, 0);
  lcd.print(HOUR = now.hour(), DEC);
  lcd.print(":");
  lcd.print(MINUT = now.minute(), DEC);
  lcd.print(":");
  lcd.print(SECOND = now.second(), DEC);
  lcd.setCursor(0, 1);
  lcd.print("Date: ");
  lcd.print(now.day(), DEC);
  lcd.print("/");
  lcd.print(now.month(), DEC);
  lcd.print("/");
  lcd.print(now.year(), DEC);
  //match();
  delay(200);

  //Manually enter time to set an alarm instead of using push buttons
  //This enters the play() function and plays the file
  //Had to add SECOND, without the code the LCD will still display the time,
  //but the speaker chirps for full minute, will play song when it goes to the next minute
  //if (HOUR == 10 && MINUT == 52 && SECOND == 00)
  {
    delay(1000);
    play();
  }
}
void defualt()
{
  lcd.setCursor(0, 1);
  lcd.print(HOUR);
  lcd.print(":");
  lcd.print(MINUT);
  lcd.print(":");
  lcd.print(SECOND);
}

// This is where things take a turn and stop working properly    **********

void time() //with this function empty the code still works and file still plays
{ // However with this function populated, whenever I try to hit a pushbutton
  // the lcd display stops functions and just displays random characters
  {
    int temp = 1, minuts = 0, hours = 0, seconds = 0;
    while (temp == 1)
    {
      if (digitalRead(INC) == 0)
      {
        HOUR++;
        if (HOUR == 24)
        {
          HOUR = 0;
        }
        while (digitalRead(INC) == 0);
      }
      /*Serial.println("Set Alarm Time ");
        //lcd.print(x);
        //lcd.setCursor(0, 1);
        Serial.print(HOUR);
        Serial.print(":");
        Serial.print(MINUT);
        Serial.print(":");
        Serial.println(SECOND);*/
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Set Alarm Time ");  //This displays
      //lcd.print(x);
      lcd.setCursor(0, 1);
      lcd.print(HOUR);   // The time displays
      lcd.print(":");
      lcd.print(MINUT); // Time displays
      lcd.print(":");
      lcd.print(SECOND); //Time displays
      delay(100);
      if (digitalRead(next) == 0) // When I hit this button, the LCD display stops working properly and                                                                //                                            //displays random characters
      {
        hours1 = HOUR;
        EEPROM.write(add++, hours1);
        temp = 2;
        while (digitalRead(next) == 0);
      }
    }

    while (temp == 2)
    {
      if (digitalRead(INC) == 0)
      {
        MINUT++;
        if (MINUT == 60)
        {
          MINUT = 0;
        }
        while (digitalRead(INC) == 0);
      }
      /* Serial.print(HOUR);
        Serial.print(":");
        Serial.print(MINUT);
        Serial.print(":");
        Serial.println(SECOND);*/
      lcd.clear();
      lcd.setCursor(0, 1);
      lcd.print(HOUR);
      lcd.print(":");
      lcd.print(MINUT);
      lcd.print(":");
      lcd.print(SECOND);
      delay(100);
      if (digitalRead(next) == 0)
      {
        minut = MINUT;
        EEPROM.write(add++, minut);
        temp = 0;
        while (digitalRead(next) == 0);
      }
    }
    delay(1000);
  }
}

// This is the end of the section that gives me the problem ********

void play()
{
  tmrpcm.setVolume(6);
  tmrpcm.play("The_view.wav");
}
  lcd.print(HOUR = now.hour(), DEC);
  lcd.print(":");
  lcd.print(MINUT = now.minute(), DEC);
  lcd.print(":");
  lcd.print(SECOND = now.second(), DEC);

Why are you assigning values to variables in a print() call? Do that separately.

The default for printing anything is base 10. Get rid of all the , DEC crap.

I'm really having trouble finding the

/* ===========================
    Last additional code that makes things fail
=========================== */

sections in your code.