In this project I wanna show you how to build simple stuffed animal toy capable to play MP3 files. I also added the possibility of nodding the toy's head, just to make it cooler. :)
You can also use this tutorial as example for connecting DFPlayer Mini to Arduino, and build your own projects like alarm clock, MP3 speaker, etc.
IdeaIdea is very simple. I press stuffed toy hand, and it plays MP3 file from MicroSD card. While playing, toy is nodding it's head.
To respond to the pressure of my hand, I inserted a piezoelectric plate in toy's hand.
For nodding, I put servo with holder inside of the toy.
Hand pressure detectionTo respond to the pressure of my hand, I inserted a piezoelectric plate in toy's hand.
To make the signal clearer, a 1M resistor should be added between the piezoelectric wires.
In order for the toy to nod its head, it was necessary to insert a holder, which would hold the servo in place. Without this, the servo would move in place. I used plastic bottle for this.
Calibrate servo based on your project setup.
void nodd()
{
servo1.write(SERVO_NODD);
delay(300);
servo1.write(SERVO_INITIAL);
}
MP3- MicroSD formatting
Format the SD card with the FAT or FAT32 file system.
- Connections
Using the Arduino to control the DFPlayer Mini requires seven connections between the DFPlayer and the Arduino.
Arduino TX (D5) <--------> DFPlayer RX (with 1K resistor)
Arduino RX (D4) <--------> DFPlayer TX
Arduino 5V
Speaker wire 1 <--------> SPK_1 pin of DFPlayer
Speaker wire 2 <--------> SPK_2 pin of DFPlayer
Digital pin (D2) <--------> BUSY pin of DFPlayer
- Library
I tried with multiple libraries, but they didn't work with my MicroSD card. I found this library and it works perfectly.
You can download library here, from RobotsForFun website.
Start mp3 module and set volume in setup()
.
// Start MP3 module
mp3.begin();
mp3.setVolume(VOLUME_INITIAL);
Play file:
mp3.playMP3Folder(1); // Play track 1 in the mp3 folder
Stop songs:
mp3.stopAll();
Use hardward to detect if playing using the DFPlayer Busy pin
mp3.playing(BUSYPIN)
You can find code in Code section. Everything is explained in comments.
- Add files to module
Create two special folders using the names mp3 and advert. 99 more folders can be added using names 01 to 99.
In order for the module to play the file, it is necessary to rename it in a certain format. MP3 files in mp3 and advert folders must starts with 4 digits ( 0001, 0002, 0003...), and then optionally a long filename after.
In other custom folders (01-99), MP3 filename must start with 3 digits (001, 002, 003..), and then optionally a long filename after. You can have up to 255 files inside these folders.
Finished projectPossible extension of the projectYou can add more piezoelectric plates for playing multiple songs, or more servos for moving head in different directions or for limbs movement.
Comments
Please log in or sign up to comment.