C:\Users\ownas\OneDrive\Documents\Arduino to9ver1 to9ver1.ino:28:1:错误:“PCM”未命名类型;您指的是“PC0”吗? PCM播放器; ^~~ 电脑0 C:\Users\ownas\OneDrive\Documents\Arduino to9ver1 to9ver1.ino:在函数“void setup()”中: C:\Users\ownas\OneDrive\Documents\Arduino to9ver1 to9ver1.ino:34:3:错误:“玩家”未在此范围内声明 玩家.setPin(12); // 将引脚 12 设置为音频输出引脚 ^~~~~~~ C:\Users\ownas\OneDrive\Documents\Arduino to9ver1 to9ver1.ino:37:18:错误:“analogWriteResolution”未在此范围内声明 Serial.println(analogWriteResolution(12)); //检查引脚12的PWM支持 ^~~~~~~~~~~~~~~~~~~~~~ C:\Users\ownas\OneDrive\Documents\Arduino to9ver1 to9ver1.ino:37:18:注意:建议替代方案:'analogWrite' Serial.println(analogWriteResolution(12)); //检查引脚12的PWM支持 ^~~~~~~~~~~~~~~~~~~~~~ 模拟写入 C:\Users\ownas\OneDrive\Documents\Arduino to9ver1 to9ver1.ino:在函数“void Loop()”中: C:\Users\ownas\OneDrive\Documents\Arduino to9ver1 to9ver1.ino:43:7:错误:“玩家”未在此范围内声明 播放器.play_P(audioFiles[i]); ^~~~~~
退出状态1
编译错误:‘PCM’没有命名类型;您指的是“PC0”吗?
#include <PCM.h>
#include <avr/pgmspace.h>
const int numButtons = 10;
const int buttons[numButtons] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; // pin numbers for buttons
const int numAudioFiles = 10;
const char audio1[] PROGMEM = { ... }; // audio data for audio file 1
const char audio2[] PROGMEM = { ... }; // audio data for audio file 2
const char audio3[] PROGMEM = { ... }; // audio data for audio file 3
// and so on for audio files 4-10
const char* audioFiles[numAudioFiles] = {audio1, audio2, audio3, audio4, audio5, audio6, audio7, audio8, audio9, audio10}; // array of pointers to audio data
PCM player;
void setup() {
for (int i = 0; i < numButtons; i++) {
pinMode(buttons[i], INPUT);
}
player.setPin(12); // setting pin 12 as the audio output pin
player.begin();
Serial.println(F("PWM supported: "));
Serial.println(analogWriteResolution(12)); //checking PWM support for pin 12
}
void loop() {
for (int i = 0; i < numButtons; i++) {
if (digitalRead(buttons[i]) == HIGH) {
player.play_P(audioFiles[i]);
while (player.isPlaying()); // wait for audio to finish
}
}
}
请帮我解决这个问题
startPlayback(Audio_file, sizeof(audioFiles[i]));
注释掉第 12 行,在这种情况下第 27 行将是
startPlayback(&audioFiles[i], sizeof(audioFiles[i]));
PCM 库没有定义 PCM 类。相反,它导出两个函数:
void startPlayback(unsigned char const *data, int length);
void stopPlayback();
请注意,该库适用于 16 MHz 的 Atmega168,并在引脚 11 上输出。
PCM 不是 Type,它是用 C 实现的。 PCM 不包含方法 play_P() 和 isPlaying()
注释掉这些行:
PCM player
player.play_P(audioFiles[i]);
while (player.isPlaying());
void startPlayback(unsigned char const *data, int length); 使用 startPlayback(&audioFiles[i], sizeof(audioFiles[i])); 音频文件 - 8 字节数组