The loop always prints the max value depending on what resolution I've set, such as 4095 by default. So in that sense the call is succeeding, but I get that value no matter whether the pin is connected to GND or 3.3 or a microphone!
So clearly I'm doing something pretty basic wrong, but what?
Code: Select all
void loop()
{
adcAttachPin(AUDIO_PIN);
adcStart(AUDIO_PIN);
analogReadResolution(10); // Default of 12 is not very linear. Recommended to use 10 or 11 depending on needed resolution.
analogSetAttenuation(ADC_6db); // Default is 11db which is very noisy. Recommended to use 2.5 or 6.
pinMode(AUDIO_PIN, INPUT);
for (;;)
{
Serial.println(analogRead(AUDIO_PIN));
}
}