Issue with reading Audio from ADC - Teensy 4.1

Julian123

New member
I set up the recommended circuit for using the ADC for sampling audio and got it working perfectly with the Teensy 3.6. The code returned the expected peak values.

Then switching over to a 4.1 (with the 10k resistor changed to a 2k resistor) the peak value failed to return any data and peak.available() returns false. All of the pins are still connected to the same pins as they were for the 3.6.

I do not have the pins available to use a shield so I would like to get the ADC method working for the 4.1.

Attached is the source code.
View attachment Audio_Tester.ino

Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>



// GUItool: begin automatically generated code
AudioInputAnalog         adc1;           //xy=227.99999618530273,267.9999885559082
AudioAnalyzePeak         peak1;          //xy=461.99999237060547,264.99999618530273
AudioConnection          patchCord1(adc1, peak1);
// GUItool: end automatically generated code



// GUItool: end automatically generated code
  long StartMillis;

void setup() {
  // put your setup code here, to run once:
   StartMillis = millis();

   Serial.begin(9600);
   delay(1000);
   AudioMemory(12);
}

void loop() {
  // put your main code here, to run repeatedly:
  
  
 if (millis()> StartMillis+10){


   StartMillis =millis();
   
       
  if (peak1.available()){
   
       float peakValue = peak1.read();
       Serial.println(peakValue);
  }else{
    Serial.println("Peak not available");
  }  
 }
}

Thanks in advance!
 
Hey Paul, Thanks for the quick response.

I tried a full uninstall of Arduino and Teensyduino and then re-installing the 1.58-beta3 and Arduino 1.8.19.
Unfortunately, the issue persists. (peak.available() never returns true and calling peak.read() always returns 1.00)
 
Since your code ran successfully on the T3.6 and not on the T4.1, and you only changed the resistor you may want to check your external hardware.
Fastest test is probably using the RMS object to see whether any audio is present at the A2 pin.

Paul
 
Thanks for the help. After checking and confirming the presence of audio I reinstalled the V1.58 and horaah suddenly it was working!
Thanks again! :)
 
Back
Top