-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleAudioPlayerZero-ARM.ino
More file actions
67 lines (51 loc) · 1.53 KB
/
SimpleAudioPlayerZero-ARM.ino
File metadata and controls
67 lines (51 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
Simple Audio Player for Arduino Zero
Demonstrates the use of the Audio library for the Arduino Zero
Hardware required :
* Arduino shield with a SD card on CS4
* A sound file named "test.wav" in the root directory of the SD card
* An audio amplifier to connect to the DAC0 and ground
* A speaker to connect to the audio amplifier
Arturo Guadalupi <a.guadalupi@arduino.cc>
Angelo Scialabba <a.scialabba@arduino.cc>
Claudio Indellicati <c.indellicati@arduino.cc>
This example code is in the public domain
http://arduino.cc/en/Tutorial/SimpleAudioPlayerZero
*/
#include <SPI.h>
#include "SdFat.h"
#include "AudioZero.h"
SdFat SD;
File myFile;
void setup()
{
// debug output at 115200 baud
SerialUSB.begin(9600);
while (!SerialUSB) {}
// setup SD-card
SerialUSB.print("Initializing SD card...");
if (!SD.begin(4)) {
SerialUSB.println(" failed!");
while(true);
}
SerialUSB.println(" done.");
// 44100kHz stereo => 88200 sample rate
//AudioZero.begin(2*44100);
AudioZero.begin(44100);
}
void loop()
{
int count = 0;
// open wave file from sdcard
myFile = SD.open("test12345678901234567890.wav", O_RDONLY);
if (!myFile) {
// if the file didn't open, print an error and stop
SerialUSB.println("error opening test.wav");
while (true);
}
SerialUSB.print("Playing Longname");
// until the file is not finished
AudioZero.play(myFile);
SerialUSB.println("End of file. Thank you for listening!");
while (true) ;
}