22
22
23
23
void setup () {
24
24
// initialize serial communication at 9600 bits per second:
25
- Serial .begin (115200 );
26
- delay ( 15000 );
25
+ SerialUSB .begin (115200 );
26
+ while (!SerialUSB );
27
27
28
28
/* Test begin() method */
29
29
while (SD.begin (SD_DETECT_PIN) != TRUE )
@@ -38,21 +38,21 @@ void loop() {
38
38
const int S = 1024 ; // Number of samples to read in block
39
39
uint32_t buffer[S];
40
40
int duration;
41
- delay (5000 ); // delay for console
41
+ delay (1000 ); // delay for console
42
42
43
43
File myFile = SD.open (" test.wav" );
44
44
if (!myFile.available ()) {
45
45
// if the file didn't open, print an error and stop
46
- Serial .println (" error opening test.wav" );
46
+ SerialUSB .println (" error opening test.wav" );
47
47
while (true );
48
48
} else {
49
- Serial .println (" test.wav open OK" );
49
+ SerialUSB .println (" test.wav open OK" );
50
50
}
51
51
52
52
myFile.read ((void *) &WaveFormat, sizeof (WaveFormat));
53
53
54
54
delay (1000 );
55
- Serial .println (" STARTUP AUDIO\r\n " );
55
+ SerialUSB .println (" STARTUP AUDIO\r\n " );
56
56
delay (1000 );
57
57
Audio.begin (WaveFormat.SampleRate , 100 );
58
58
@@ -68,7 +68,7 @@ void loop() {
68
68
// Every 100 block print a '.'
69
69
count++;
70
70
if (count == 1000 ) {
71
- Serial .print (" ." );
71
+ SerialUSB .print (" ." );
72
72
count = 0 ;
73
73
}
74
74
// read from the file into buffer
@@ -78,11 +78,11 @@ void loop() {
78
78
Audio.write (buffer, sizeof (buffer));
79
79
}
80
80
/* reaching end of file */
81
- Serial .println (" End of file. Thank you for listening!" );
81
+ SerialUSB .println (" End of file. Thank you for listening!" );
82
82
Audio.end ();
83
83
myFile.close ();
84
84
85
85
delay (5000 );
86
- Serial .println (" Restart Playing" );
86
+ SerialUSB .println (" Restart Playing" );
87
87
88
88
}
0 commit comments