File tree 1 file changed +15
-2
lines changed
libraries/PDM/examples/PDMSerialPlotter 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change 5
5
6
6
Circuit:
7
7
- Arduino Nano 33 BLE board
8
+ - Arduino Portenta H7 board
8
9
9
10
This example code is in the public domain.
10
11
*/
11
12
12
13
#include < PDM.h>
13
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
+
14
21
// buffer to read samples into, each sample is 16-bits
15
- short sampleBuffer[256 ];
22
+ short sampleBuffer[512 ];
16
23
17
24
// number of samples read
18
25
volatile int samplesRead;
@@ -30,7 +37,7 @@ void setup() {
30
37
// initialize PDM with:
31
38
// - one channel (mono mode)
32
39
// - a 16 kHz sample rate
33
- if (!PDM.begin (1 , 16000 )) {
40
+ if (!PDM.begin (channels, frequency )) {
34
41
Serial.println (" Failed to start PDM!" );
35
42
while (1 );
36
43
}
@@ -42,6 +49,12 @@ void loop() {
42
49
43
50
// print samples to the serial monitor or plotter
44
51
for (int i = 0 ; i < samplesRead; i++) {
52
+ if (channels == 2 ) {
53
+ Serial.print (" L:" );
54
+ Serial.print (sampleBuffer[i]);
55
+ Serial.print (" R:" );
56
+ i++;
57
+ }
45
58
Serial.println (sampleBuffer[i]);
46
59
}
47
60
You can’t perform that action at this time.
0 commit comments