Audio Input for microcontroller

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
kylefoster
 
Posts: 82
Joined: Fri Jul 22, 2016 7:07 am

Audio Input for microcontroller

Post by kylefoster »

Hi Guys,

I know this is a common topic in general but I'm struggling to find something specific for my current setup. I've got an LED Matrix with a pro mini integrated onto the board. The board has 6 usable inputs (3 of which are in use). I want to utilise one or all of the remaining inputs for other functions for the matrix to perform for advertising purposes.

One idea was to simply hook up an audio source and have the matrix perform to some music. How do I get an audio source into one of the inputs? Do I need an amplifier breakout with a 3.5mm jack input for example? Ideally, I would like a board with one input (for the audio source) and one output to one of the remaining inputs on the board. Or is it even simpler than this such as just stripping one end of a 3.5mm cable? I'm not sure what voltage is outputted by a audio source such as an MP3 player or phone etc.

There seems to be no shortage of code to support these projects so I should be ok on that front but not sure about the hardware.

How is this usually achieved?

Many thank in advance,

Kyle

User avatar
kylefoster
 
Posts: 82
Joined: Fri Jul 22, 2016 7:07 am

Re: Audio Input for microcontroller

Post by kylefoster »

I've seen this which looks incredibly simple which is ideal apart from it using a microphone as apposed to just hooking up an MP3 player/phone using a 3.5mm jack:

https://learn.adafruit.com/trinket-soun ... g?view=all

Would this do the job or is there more to it:

https://www.sparkfun.com/products/11570

I assume the microphone is converting analog to digital? Or is it using an analog input?

Thanks again,

Kyle

User avatar
kylefoster
 
Posts: 82
Joined: Fri Jul 22, 2016 7:07 am

Re: Audio Input for microcontroller

Post by kylefoster »

Would a SparkFun Spectrum Shield help here or is it essential to be attached to an uno? I'm having trouble getting my head around how many inputs it requires considering I only have 3 to work with etc.

Thanks again,

Kyle

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: Audio Input for microcontroller

Post by adafruit_support_mike »

The microphone's output is an analog signal, but the microcontroller's ADC pins convert that to a digital signal.

The color organ project is as good a place to start as any. You don't need an Uno or a shield, just a mic breakout connected to one of the microcontroller's analog pins.

User avatar
kylefoster
 
Posts: 82
Joined: Fri Jul 22, 2016 7:07 am

Re: Audio Input for microcontroller

Post by kylefoster »

Thanks Mike,

Is there an equivalent for a 3.5mm jack? The mic breakout is very simple as you say but I can't find one that just has a jack.

My intention is to show these LEDs at shows for advertising and I'd be worried about ambient noise in that sort of environment compared to a 'pure' MP3 file for example.

Thanks again,

Kyle

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: Audio Input for microcontroller

Post by adafruit_support_mike »

You can wire an audio jack into a breadboard and connect that to one of the analog pins:

https://www.adafruit.com/product/1699

We also have an adapter that breaks the cable signals out to terminal blocks:

https://www.adafruit.com/product/2791

User avatar
kylefoster
 
Posts: 82
Joined: Fri Jul 22, 2016 7:07 am

Re: Audio Input for microcontroller

Post by kylefoster »

Thanks again Mike,

So I won't need anything else to make this work? I thought the mic breakout might have some sort of converter or amplifier inside it to act as 'middle man' between the audio source and arduino. I'll give the 3.5mm jack a go using the colour organ for the code etc.

Kyle

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: Audio Input for microcontroller

Post by adafruit_support_mike »

The mic breakout does have a built-in amplifier, but an audio source that plays MP3s will have an equivalent amplifier for its output. In general, a microcontroller's ADC can read the same signals that drive a set of headphones.

You might need to write some test code to see what set of values you get from the ADC, and modify the code to work with those, but that will mostly involve changing some constants.

User avatar
wwaver
 
Posts: 17
Joined: Tue May 30, 2017 10:06 am

Re: Audio Input for microcontroller

Post by wwaver »

Did this work for you for a Line Input?
I am placing a NeoPixel reactive light fixture in a public space and would like to give it line level music. I have it wired and working with the Mic breakout. Would I just wire - negative audio to ground and + audio to an analog input? Using two analog inputs I could have stereo isolation?

Using a feather MO.

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: Audio Input for microcontroller

Post by adafruit_support_mike »

It depends on the kind of audio signal you have coming in.

There are two ways to transmit audio, called 'balanced' and 'unbalanced' signals. With a balanced signal, the voltage on both wires changes, and the voltages are always centered around 0V. The no-signal condition puts both lines at 0V. With an unbalanced signal, one line stays at GND and the other swings between 0V and about 1V. The no-signal condition puts the non-GND line at about 500mV.

It's easy to connect multiple unbalanced signals to a microcontroller because the active lines are always measured relative to the same GND line. It's harder to connect multiple balanced signals though, because no two wires are likely to be at the same voltage at any moment.

To connect balanced lines to a microcontroller, you need two 10k-10k voltage dividers between VCC and GND. Connect a 1uF capacitor between each incoming signal line and the center of one of the voltage dividers, then connect the center of one divider to an ADC pin. That will center the signal on that line at VCC/2 (1.65V for a Feather) so the ADC can read it.

User avatar
wwaver
 
Posts: 17
Joined: Tue May 30, 2017 10:06 am

Re: Audio Input for microcontroller

Post by wwaver »

I am hoping to send line level output from a DJ software like Serato or Resolume. The MAX4466 does a great job with bass heavy music and it makes a great VU effect with guitars in the room but I'd like to send to the feather from a mixing console. Using an Aux send I could provide an unbalanced signal without any issue. Typically I use a USB to audio interface like a Focusrite Scarlett, which has 2 unbalanced RCA outputs.

I guess my only concern is there any issue with this wiring setup? I am a little concerned about power ground being connected to audio interfaces. Staying with unbalanced only should any wiring be changed here?
Music to Feather.JPG
Music to Feather.JPG (147.32 KiB) Viewed 881 times

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: Audio Input for microcontroller

Post by adafruit_support_mike »

Unbalanced signals use one grounded line, and it should be safe to connect that to the Feather's GND as long as you don't do anything weird with the power supplies.

You can check the signals by measuring the voltage between the audio-GND and Feather-GND before making the wired connections. You shouldn't see any DC offset, but if you do, you'll know that something strange is happening in the audio signal path.

There are ways to cope with that, but it's easier to see if you need them first.

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”