I am very obsessed with music, and when I was new in electronics, the first thing I wanted to do (after blinking a LED of course) was to make a Music operated light, that will turn on and off according to the music's up and down. So I bought a sound sensor. But that didn't give me what I wanted. They have digital output, meaning, they can give either low signal or high signal as the output. Nothing in between them. Due to that, my "disco light" kind of sucked. Sometimes later I studied Operational Amplifier (Op-Amp) and their various configurations (in my college). After spending a little time on the internet, I came up with a circuit that can give me Analog outputs from music. So that I can write that Analog output in a Microcontroller. That gave me a nice little effect I wanted. Well, I didn't get much deeper, but that circuit can do much more things than just what we're going to do here. It's just a kickstart for several bigger projects.
So let's get started.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: The Op-Amp
We won't go much into educational stuff, but an Operational amplifier is a high gain electronic voltage amplifier. It has high input and low output impedance. We generally use op amp with a feedback (a part of output is taken back and fed to the input). This gives us controlled output voltage.
Now, there are hundreds of configurations in which they are used (and relatively thousands of applications). We'll be using two widely used configurations:
Non inverting amplifier
Step 2: The Real Op-Amp
The op-amp come as integrated circuits, out of which two are mainly and widely used:
The main difference between both is that 324 has 4 op amps and 358 has 2. We require two op-amps (for amplifying signal from one channel, either left or right), and its up to you which one to use (I'll be using LM324. Check datasheet for LM358). Both IC work on a 5V voltage level. The pin diagram of LM324 is attached.
Step 3: The Configurations Used
Generally op amp has 2 inputs (inverting and non inverting) and 1 output. Inverting input is shown by a negative sign in the op amp while non inverting input is shown by the positive sign (see the picture in Step 1).
1. Non inverting amplifier: The set up for a non inverting amplifier is shown in the figure. The ratio of output and input is called gain, and in this configuration, gain is characterized by the equation shown by Av in the picture. So for a feedback resistance of 10k and input resistance of 1k, the gain will be 11. That means output will be 11 times the input. But that doesn't mean a 2V input will give 22V output because an op amp has a positive and a negative rail. In other words, op amp has a certain reference level. If op amp tries to amplify it to 22V, it can only go to 5V. Better think of a scale we assume for bigger values while plotting graph for something.
2. Voltage follower: This is a simple circuit and it just gives the output as it is given in the input. The requirement for this circuit is to separate the output from all the chit-chat going on in the non inverting amplifier circuit.
After voltage follower, we'll be using a RC filter that resistors the sudden drops and ups coming from the music and the LED fades instead of turning on and off, giving a nice effect.
Step 4: The Set Up
First you will need a 3.5 mm jack lead, cut and strip it to get the three wires inside it (left, right and common). Now I suppose you know how to use that (if not, just comment). I have attached a picture of how it looks like. Now we will use any of the left or right as the as the input to op amp. The set up is shown in figure.
What are we doing?
We all know that the signal running in the wire of the headphone/earphone is nothing but a voltage level. But they are of very low magnitude. It's that much low, that we can't even light up a led with it. To amplify or increase the magnitude, we will use a non inverting amplifier. Audio signal is given in the non inverting input of the circuit. The rest of the circuit takes care of all other stuff.
To check if it's working just add a LED with a current limiter at the output of voltage follower. If your circuit is correct, the LED will light up according to your music.
Note that the common of the jack must be grounded with the ground rail of the circuit.
Step 5: Getting Analog Values
I have attached a simple Arduino sketch that reads the output and displays it in the serial monitor. The analog input is taken from the output of voltage follower obviously. The pin used is A0. Just upload the sketch to your Arduino, connect your circuit output, open serial monitor and BOOM! You just made yourself a circuit that gives analog values from audio signal.
Step 6: The Problem!
There's just one problem I've been facing. Due to the use of 3.5 mm jack, I can either feed it to the amplifier circuit or I can listen music. But if you change settings from your audio manager so as to get the output from both front and rear panel jack, then you can use the rear jack for your speaker and you can get that same signal from front panel which you can use to for your circuit. In case you are using your phone to do so, you can use a good quality audio splitter (search the internet for more information on audio splitter).
Well that's what I was doing so far, if you have any other cool ideas to overcome this problem, let me know :).
Step 7: And DONE!
Now go ahead and use that analog value you got to do something cool like controlling a RGB digital LED strip or something. Let me know what did you make.
Thanks for reading. :)