Daniel Caesar MP3 Player
Devin & Estee
Daniel Caesar MP3 Player
Devin & Estee
What I wanted to learn, and why it interested me: We wanted to learn how to use the DFplayer mini and experiment with sound! We haven't explored this topic before, so we wanted to venture out:)
Final outcome: A mp3 player with 3 buttons to play 3 different Daniel Caesar tracks. A potentiometer controls volume.
Final creative output
Our little mp3 player!
Video of our working product.
Process
Trying to work out the hardware... the speaker ended up being broken...
Figuring out how to use the dfmini player & speaker... We couldn't get it to work because we used the wrong resistor!
Process and reflection:
When we initially began our exploration with sound, we struggled a bit to get the speaker to work. Part of this struggle came from the fact that we kept using broken speakers (and we didn't export the mp3 files properly). But the main problem we had was simply using the wrong resistor, causing the whole sound system to fail.
After we realized our issues, we switched to a better functioning speaker component and were able to quickly come up with our creative output. While experimenting, we also realized that the speaker sound quality improved when we used a 1k ohm resistor between the DFplayer mini's rx to arduino connection. Although the static sound still prevailed, the sound was a lot more crisp.
Overall, both of us found this exploration a bit challenging but very rewarding in the end, especially since we now have a pocket Daniel Caesar mp3 player we can listen to at any given time! Now, we are also more careful to pick out the right resistor and save hours of debugging and rewiring...
Technical details
Electrical Schematic: The 1K ohm resistor was used to stabilize the speaker sound, as it was a bit static without it.
//code base came from copilot! songs are all Daniel Caesar :)
//track 1: get you
//track 2: best part
//track 3: superpowers
Arduino pin | role | details
------------------------------
A0 input potentiometer
2 input tactile button switch
3 input tactile button switch
4 input tactile button switch
10 output DF Player Mini
11 ourpur DF Player Mini
#include <SoftwareSerial.h>
#include <DFRobotDFPlayerMini.h>
SoftwareSerial mySerial(10, 11); // TX, RX for serial communication
DFRobotDFPlayerMini myDFPlayer;
const int buttonPins[] = {2, 3, 4}; // Button pins
const int trackNumbers[] = {1, 2, 3}; // Corresponding tracks
bool lastStates[] = {HIGH, HIGH, HIGH};
const int potPin = A0; // Potentiometer connected to A0
int lastVolume = -1; // To track volume changes
void setup() {
for (int i = 0; i < 3; i++) {
pinMode(buttonPins[i], INPUT_PULLUP);
}
Serial.begin(9600);
mySerial.begin(9600);
if (!myDFPlayer.begin(mySerial)) {
Serial.println("Unable to begin DFPlayer Mini");
while (true);
}
myDFPlayer.volume(20); // Initial volume from range of 0-30
}
void loop() {
// Check buttons
for (int i = 0; i < 3; i++) {
bool currentState = digitalRead(buttonPins[i]);
if (lastStates[i] == HIGH && currentState == LOW) {
myDFPlayer.play(trackNumbers[i]);
delay(200); // Debounce
}
lastStates[i] = currentState;
}
// Read potentiometer and update volume
int potValue = analogRead(potPin); // 0–1023
int volume = map(potValue, 0, 1023, 0, 30); // DFPlayer volume range
if (volume != lastVolume) {
myDFPlayer.volume(volume);
lastVolume = volume;
}
delay(50);
}