如何判断我的 SD.h 和 TMRpcm.h 库是否兼容?

how can i tell if my SD.h and TMRpcm.h libraries are compatible?

提问人:noob9000 提问时间:10/7/2023 最后编辑:Progmannoob9000 更新时间:10/7/2023 访问量:34

问:

我正在尝试让 Arduino Nano 播放 WAV 文件,但它不起作用。

接线看起来不错,代码似乎还可以;

ChatGPT 认为,问题可能的可能原因之一可能是我安装的库不兼容。我已经阅读了自述文件文档,但没有看到任何关于此的注释。

如何检查我安装的版本是否兼容? 或者,如果这些库依赖于我忽略安装的其他库??

your text

代码上传正常

我拨动开关,什么也没发生

它应该播放一个 WAV 文件。事实并非如此

这是上传的代码:

#include <SD.h>
#include <TMRpcm.h>

#define SD_CS_PIN 10   // CS pin for the SD card reader
#define SWITCH_PIN 2   // Pin connected to the switch
#define LASER_PIN 3    // Pin connected to the laser
#define SD_MISO_PIN 12 // MISO pin
#define SD_MOSI_PIN 11 // MOSI pin
#define SD_SCK_PIN 13  // SCK pin
TMRpcm audio;

void setup() {
pinMode(SWITCH_PIN, INPUT_PULLUP);  // Enable the internal pull-up resistor
audio.speakerPin = 5;  // Set the speaker pin (any available PWM pin)
Serial.begin(9600);

if (!SD.begin(SD_CS_PIN)) {
Serial.println("SD card initialization failed!");
while (1);
}

audio.setVolume(5);  // Set the volume (0 to 7)
}

void loop() {
if (digitalRead(SWITCH_PIN) == LOW) {
playSound("mp3/tos_phaser_7_01.wav");  // Play the WAV file when the switch is pressed
}
}

void playSound(const char* filename) {
if (audio.isPlaying()) {
audio.stopPlayback();
}
audio.play(filename);
}
C 兼容性 SD 卡 nano

评论


答: 暂无答案