C:\Users\ownas\OneDrive\Documents\Arduino\0to9ver1\0to9ver1.ino:28:1: error: 'PCM' does not name a type; did you mean 'PC0'? PCM player; ^~~ PC0 C:\Users\ownas\OneDrive\Documents\Arduino\0to9ver1\0to9ver1.ino: In function 'void setup()': C:\Users\ownas\OneDrive\Documents\Arduino\0to9ver1\0to9ver1.ino:34:3: error: 'player' was not declared in this scope player.setPin(12); // setting pin 12 as the audio output pin ^~~~~~ C:\Users\ownas\OneDrive\Documents\Arduino\0to9ver1\0to9ver1.ino:37:18: error: 'analogWriteResolution' was not declared in this scope Serial.println(analogWriteResolution(12)); //checking PWM support for pin 12 ^~~~~~~~~~~~~~~~~~~~~ C:\Users\ownas\OneDrive\Documents\Arduino\0to9ver1\0to9ver1.ino:37:18: note: suggested alternative: 'analogWrite' Serial.println(analogWriteResolution(12)); //checking PWM support for pin 12 ^~~~~~~~~~~~~~~~~~~~~ analogWrite C:\Users\ownas\OneDrive\Documents\Arduino\0to9ver1\0to9ver1.ino: In function 'void loop()': C:\Users\ownas\OneDrive\Documents\Arduino\0to9ver1\0to9ver1.ino:43:7: error: 'player' was not declared in this scope player.play_P(audioFiles[i]); ^~~~~~
exit status 1
Compilation error: 'PCM' does not name a type; did you mean '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
}
}
}
please help me with this
CodePudding user response:
The PCM library does not define a PCM class. Instead, it exports two functions:
void startPlayback(unsigned char const *data, int length);
void stopPlayback();
Note that this library is made to work with an Atmega168 at 16 MHz, and outputs on pin 11.
CodePudding user response:
<PCM.h> Provides only two Methods and doesn't define a type named PCM. Declaration of PCM in line 12 will Cause an Error. What you're trying to achieve is void startPlayback(unsigned char const *data, int length);
The Syntax of PCM Playback is:
startPlayback(Audio_file, sizeof(audioFiles[i]));
Comment out line 12, In this case 27th Line will be
startPlayback(&audioFiles[i], sizeof(audioFiles[i]));