Camila_99$$
Camila_99$$
DIIDevHeads IoT Integration Server
Created by Camila_99$$ on 7/23/2024 in #firmware-and-baremetal
Arduino Uno Playing Slow Motion Sound from SD Card - Need Help!
Morning guys, I have connected an Arduino Uno with two speakers and a DFR0071 SD card module. The problem is when I play the recorded sound in .wav format, it plays in slow motion. Do you have any ideas? Because I'm completely stuck, thanks. Here is the code I am using:
#include <SD.h>
#include <TMRpcm.h>
#include <SPI.h>

#define SD_ChipSelectPin 10 // CS pin for the SD card
#define SpeakerPin 9 // Pin for the speaker (use pin 9 on the Arduino Uno)

TMRpcm audioPlayer; // Create an object for the speaker control library

void setup() {
// Start the serial communication for debugging purposes
Serial.begin(9600);

// Check if the SD card is present and initialized
if (!SD.begin(SD_ChipSelectPin)) {
Serial.println("SD card initialization failed!");
return; // Stop if it's not initialized
}

audioPlayer.speakerPin = SpeakerPin; // Define the speaker pin
audioPlayer.setVolume(7); // Set the volume (0 to 7)
audioPlayer.quality(1); // Set audio quality (0 for low, 1 for high)

Serial.println("SD card initialized.");
}

void loop() {
Serial.println("Playing audio...");
audioPlayer.play("1.wav"); // Play the audio file named "1.wav" from the SD card
delay(3000); // Delay to allow the audio to play
audioPlayer.disable(); // Disable the audio player
delay(2000); // Delay before the next loop iteration
}
#include <SD.h>
#include <TMRpcm.h>
#include <SPI.h>

#define SD_ChipSelectPin 10 // CS pin for the SD card
#define SpeakerPin 9 // Pin for the speaker (use pin 9 on the Arduino Uno)

TMRpcm audioPlayer; // Create an object for the speaker control library

void setup() {
// Start the serial communication for debugging purposes
Serial.begin(9600);

// Check if the SD card is present and initialized
if (!SD.begin(SD_ChipSelectPin)) {
Serial.println("SD card initialization failed!");
return; // Stop if it's not initialized
}

audioPlayer.speakerPin = SpeakerPin; // Define the speaker pin
audioPlayer.setVolume(7); // Set the volume (0 to 7)
audioPlayer.quality(1); // Set audio quality (0 for low, 1 for high)

Serial.println("SD card initialized.");
}

void loop() {
Serial.println("Playing audio...");
audioPlayer.play("1.wav"); // Play the audio file named "1.wav" from the SD card
delay(3000); // Delay to allow the audio to play
audioPlayer.disable(); // Disable the audio player
delay(2000); // Delay before the next loop iteration
}
4 replies