File tree 1 file changed +14
-2
lines changed
libraries/PDM/examples/PDMSerialPlotter
1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change 12
12
13
13
#include < PDM.h>
14
14
15
+ // default number of output channels
16
+ static const char channels = 1 ;
17
+
18
+ // default PCM output frequency
19
+ static const int frequency = 16000 ;
20
+
15
21
// Buffer to read samples into, each sample is 16-bits
16
- short sampleBuffer[256 ];
22
+ short sampleBuffer[512 ];
17
23
18
24
// Number of audio samples read
19
25
volatile int samplesRead;
@@ -33,7 +39,7 @@ void setup() {
33
39
// - one channel (mono mode)
34
40
// - a 16 kHz sample rate for the Arduino Nano 33 BLE Sense
35
41
// - a 32 kHz or 64 kHz sample rate for the Arduino Portenta Vision Shield
36
- if (!PDM.begin (1 , 16000 )) {
42
+ if (!PDM.begin (channels, frequency )) {
37
43
Serial.println (" Failed to start PDM!" );
38
44
while (1 );
39
45
}
@@ -45,6 +51,12 @@ void loop() {
45
51
46
52
// Print samples to the serial monitor or plotter
47
53
for (int i = 0 ; i < samplesRead; i++) {
54
+ if (channels == 2 ) {
55
+ Serial.print (" L:" );
56
+ Serial.print (sampleBuffer[i]);
57
+ Serial.print (" R:" );
58
+ i++;
59
+ }
48
60
Serial.println (sampleBuffer[i]);
49
61
}
50
62
You can’t perform that action at this time.
0 commit comments