Hello everyone. I am new here. So I hope I can choose the right topic for my problem.
My project is ringing clock with using lcd display, sd card, rtc and speaker.
I want to play the .wav sound for example when clock is 18.00 pm. Until 18.00 on my lcd display the clock is normally working. But when the sound begining to play, clock is freezing and not working until the sound finishes. After the sound finish, clock is working normally again.
I hope I can explain clearly. Sorry for my English
So how can I fix this guys?
Here is my code:
#include <SimpleSDAudio.h>
#include <virtuabotixRTC.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
int CLK_PIN = 6;
int DAT_PIN = 7;
int RST_PIN = 8;
virtuabotixRTC myRTC(CLK_PIN, DAT_PIN, RST_PIN);
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
//myRTC.setDS1302Time(00,47,16,2,14,04,2020);
lcd.begin();
SdPlay.setSDCSPin(4);
if(!SdPlay.init(SSDA_MODE_HALFRATE | SSDA_MODE_MONO | SSDA_MODE_AUTOWORKER)){
while(1);
}
}
void loop() {
myRTC.updateTime();
lcd.clear();
lcd.setCursor(0,0);
lcd.print(myRTC.dayofmonth);
lcd.print("/");
lcd.print(myRTC.month);
lcd.print("/");
lcd.print(myRTC.year);
lcd.setCursor(0,1);
lcd.print(myRTC.hours);
lcd.print(":");
lcd.print(myRTC.minutes);
lcd.print(":");
lcd.print(myRTC.seconds);
delay(1000);
if(myRTC.hours == 17 && myRTC.minutes == 30){
if(!SdPlay.setFile("ezan.wav")){
while(1);
}
SdPlay.play();
myRTC.updateTime();
while(!SdPlay.isStopped()){
;
}
}
}