Audio Input to Arduino




The easiest way to connect an audio signal to your arduino, is to build a simple 3 components (2 resistors plus cap) circuitry shown on the first drawings on right side. Disadvantage: there is no amplifier, and consequently sensitivity would be low, hardly enough to work with headphones jack output.  For low level signals, like output of electret microphone, amplifier is necessary. Here is the kit, which included board, electronic components and NE5532 Operational Amplifier IC:

Audio Input to Arduino




Super Ear Amplifier Kit

Other option, from SparkFun Electronics:

Breakout Board for Electret Microphone

Note: I don’t recommend to replace NE5532 OPA with popular  LM358 or LM324 due their pure frequency response above > 10 kHz.

Configuring AtMega328 ADC to take input samples faster:

void setup() {

   ADCSRA = 0×87; // freq = 1/128, 125 kHz. 13 cycles x 8     usec =  104 usec.
// ADCSRA = 0×86; // freq = 1/64,   250 kHz. 13 cycles x 4     usec =   52 usec.
// ADCSRA = 0×85; // freq = 1/32,   500 kHz. 13 cycles x 2     usec =   26 usec.
// ADCSRA = 0×84; // freq = 1/16 ,    1 MHz. 13 cycles x 1      usec =   13 usec.
// ADCSRA = 0×83; // freq = 1/8,       2 MHz. 13 cycles x 0.5   usec =  6.5 usec.
// ADCSRA = 0×82; // freq = 1/4,       4 MHz. 13 cycles x 0.25 usec = 3.25 usec.

ADMUX    = 0×40;                          // Select  Analog Input 0

ADCSRA |= (1<<ADSC);                 // Start Conversion

Timer1.initialize(T_PERIOD);           // Sampling with TimerOne library
Timer1.attachInterrupt(iProcess);

}

Reading and storing samples to array via ISR ( Timer Interrupt Subroutine ), Timer1 in this example:

Audio Input to Arduino Schematic

void iProcess()
{
static uint8_t n_sampl;
if (ADCSRA & 0×10)
{
int16_t temp = ADCL;
         temp += (ADCH << 8);
          temp -= sdvigDC;    
    ADCSRA |= (1<<ADSC);
xin[n_sampl] = temp;
}

if (++n_sampl >= FFT_SIZE )
{
n_sampl = 0;
process = 1;
}

}

Don’t like to solder all this components from the drawings above? Here is easy way around, if you, by chance, have a spare USB speakers. Something like this:

Major Components in Project

Arduino

 

For more detail: Audio Input to Arduino

We recommend EasyEDA for electronic circuit design.
From Schematic Drawing to PCB Production, Just Need One Tool
Cheap PCB Prototype: 10 pcs 2 layers only $10, quick delivery, 100% E-test







This Post / Project can also be found using search terms:

  • arduino sound input
  • audio input select arduino
Clip to Evernote

Leave a Comment

(Spamcheck Enabled)

Read previous post:
Burn Arduino Bootloader on Atmega-328 TQFP and DIP chips on Breadboard
Burn Arduino Bootloader on Atmega-328 TQFP and DIP chips on Breadboard

Parts required (Hardware) Arduino Uno Board (1) TQFP 32 to DIP 28 Adapter (1) Link Atmega TQFP 32 pin chip...

Close
Scroll to top