Why am I seeing negative values at all (should be gated by the I2S.available() check)? And why am I seeing more than -1 (it returns -1 if nothing..?)
Code:
Code: Select all
void setup() {
// setup 42 PDM clock and 41 PDM data pins
I2S.setPinsPdmRx(42, 41);
// start I2S at 16 kHz with 16-bits per sample
if (!I2S.begin(I2S_MODE_PDM_RX, 16000, I2S_DATA_BIT_WIDTH_16BIT, I2S_SLOT_MODE_MONO)) {
Serial.println("Failed to initialize I2S!");
while (1); // do nothing
}
}
void loop() {
if (I2S.available() > 0) {
// Read data from microphone
int8_t sample = I2S.read(); // -1 if no data is available or an error occurred.
Serial.println(sample);
}
}Code: Select all
-17
-14
-11
-6
-3
4
9
14
20
23
28
29
30