I am building a Retro Telephone prop using an Arduino Nano with a DFPlayer Mini Module and everything is working fine up to lifting the receiver and hearing a Dial Tone through the Handset Speaker.
Until a number is Pressed on the Push button Keypad, I want to have a continuous "Dial Tone" playing through the Handset Speaker.
To achieve this I have the dial tone mp3 file in a Folder labeled "01" and the mp3 file inside that folder labeled 001dial_tone.mp3
This all works fine and when the Receiver is lifted, the dial tone can be heard, and when the Receiver is replaced, the dial tone is silenced.
I am using the player.loop(1) command to loop around the dial tone file, waiting for a number on the Telephone Keypad to be pressed. Unfortunately after each time the file is looped, there is a small interruption in sound between the sound file ending and starting to play again.
I was wondering if there was any way to avoid this slight interruption in play back.
I could obviously have a very very long dial tone mp3 track and hope someone presses a button before the track loops around ???
Code Extract below,
Regards,
Fimez.
void loop() {
// read the receiver input pin:
receiverState = digitalRead(receiverPin);
// compare the receiverState to its previous state
if (receiverState != lastReceiverState) {
// if the state has changed, play the Dial Tone
if (receiverState == LOW) {
// if the current state is LOW then the receiver is off the hook.
Serial.println("Receiver Is Off The Hook");
player.loopFolder(1);
}
else {
// if the current state is HIGH then the receiver is on the hook.
Serial.println("Receiver Is On The Hook");
player.pause();
}
// Delay a little bit to avoid Hook Switch Bouncing.
delay(50);
}