Rohan Barnwal
Published © GPL3+

Reviving the Gramophone: A Hand-Built Antique Speaker

What happens when you take the most "smart home" component on the market

IntermediateShowcase (no instructions)1 hour26
Reviving the Gramophone: A Hand-Built Antique Speaker

Things used in this project

Hardware components

Arduino UNO R4 WiFi
Arduino UNO R4 WiFi
×1
DFPlayer - A Mini MP3 Player
DFRobot DFPlayer - A Mini MP3 Player
×1
Cavity Speaker
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

Code

Arduino
#include "DFRobotDFPlayerMini.h"

DFRobotDFPlayerMini player;
int currentTrack = 0;

void setup() {
  Serial.begin(115200);
  Serial1.begin(9600);
  Serial.setTimeout(50);  // important
  delay(1000);

  Serial.println("Ready... (1-10, p, s)");

  if (player.begin(Serial1)) {
    Serial.println("DFPlayer Detected ✅");
    player.volume(20);
  } else {
    Serial.println("DFPlayer NOT Detected ❌");
  }
}

void loop() {
  if (Serial.available()) {
    String cmd = Serial.readStringUntil('\n');
    cmd.trim();   // removes \r and spaces

    if (cmd == "s") {
      player.stop();
      Serial.println("Stopped ⏹");
    }
    else if (cmd == "p") {
      if (currentTrack > 0) {
        player.start();
        Serial.println("Resumed ▶");
      } else {
        Serial.println("No track ❌");
      }
    }
    else {
      int trackNumber = cmd.toInt();
      if (trackNumber > 0 && trackNumber <= 10) {
        currentTrack = trackNumber;
        Serial.print("Playing: ");
        Serial.println(trackNumber);
        player.play(trackNumber);
      } else {
        Serial.println("Invalid ❌");
      }
    }
  }
}

Credits

Rohan Barnwal
45 projects • 39 followers
Rohan Barnwal - maker, hacker, tech enthusiast. I explore new tech & find innovative solutions. See my projects on hackster.io!

Comments