Hi,
I am planning a project where i can let multiple LED Strips react to the frequencies of music. I got the code, but I'm looking for the best way to get the audio signal to the Arduino.
My idea was to hook up my phone to a regular Audio cable and connect that cable to the Arduino. I thought about using a microphone but decided that the output is not really precise enough (I want to process the input via FHT).
Therefore i thought about connecting it via an audio cable.
My problem is that i dont really know anything about the electronics there. What would you suggest is the best way to realise that?
I read a little bit about it and it seems that i should "lift" the voltage about 2,5 V so that it is always positive. I do know how to do that but is there anything else required ( amplifier, filter etc.)?
I thought about using a microphone but decided that the output is not really precise enough
A microphone is precise, so what do you mean.
In order to get audio into an Arduino you need two resistors on the analogue input, one end of one goes to 5V and the other end of the other goes to ground. Use 10K. Then add a 1uF cap to the input and feed your audio between that and ground.
However you do need the audio voltage to be 2.5V peak, if you do not have a source that gives that out you have to amplify it. The front end of this circuit shows this arrangement.
Well i worked with a microphone for another project already, I used the FHT back then aswell and as soon as the microphone wasnt next to the speakers the output wasnt really useful (Seen in a visualizing programm). There were many background noises aswell (I had some filters but there was still much left). Thats why I had to use the fht_lin_out8 function which only has a 8 bit resolution, this was I got atleast rid of the background noises, though that kind of happened to the cost of a really precise output.
The poor resolution wasnt really a problem back then since the code was rather simple.
As I by now know a little bit more about coding, I was thinking of using a more complicated code which also requires a more precise output of the fht.
I believe the output of the audio over the cable was about 1V peak. So baisically a wave going between 1,5 and 3,5 V max. is that not enough to get a nice input for the FHT? (Of course from 0 to 5V would be better)
Since the ADC of the Arduino is 10 bit (1023 values between 0 and 5V) , that would equal about 400 Values between the lowest and highest voltage right? Would that be sufficient or should i try to amplify it with a chip for example the 2n3904?
, though that kind of happened to the cost of a really precise output.
No, precision is not the same thing as output. What you are describing is lack of output. Lack of precision would mean that the microphone was not faithfully reproducing the shape of the waveform it was picking up.
that would equal about 400 Values between the lowest and highest voltage right?
Yes.
Would that be sufficient or should i try to amplify it
I would amplify it or use an external voltage reference of 2V and bias the input at 1V.
for example the 2n3904
??
That is not a chip it is a transistor!
You want an op amp like MCP602.
Alright, thanks for the anwser!
Sorry for the mistakes, english is not my native language and i kinda got the chip and transistor mixed up.
I will try the op amp then.
Try it first, before you add an amplifier. A line-level audio signal (such as the audio-out jacks on your TV or DVD player) or a fairly-loud headphone signal should work. Use the serial monitor to check the digital readings you are getting.
The signal level depends on the equipment you are using (line-level outputs vary a bit), on how loud the recording is, and the volume control setting.
My lighting effects don't use any frequency analysis, but I use a "trick"... I save a reading once per second in a 20-second [u]circular buffer[/u]. From that array (buffer) I can get the average or peak* over the past 20 seconds and automatically-continuously calibrate the sensitivity. For example, my VU meter effect uses the peak as the "top" of the VU meter. (Of course this makes a lousy VU meter because the readings don't mean anything... But it makes a good meter effect.)
If you want to use this trick, you may want save reference levels for each of your frequency bands.
...I use another trick of switching automatically to the 1.1V reference when the signal is low. But, you can't do that with a 2.5V biased AC signal. I use a peak detector circuit that converts the AC audio signal to a varying DC signal. That way, it doesn't need to be biased and I can use a very-low sample rate of about 10Hz. But of course, that DC signal doesn't contain any frequency information.
With these two tricks, I don't need an amplifier.
Since I'm only saving a reading once per second, I the array might not hold the true-peak, but I can find the peak value and use array-peak as a reference.
It is basically an Arduino, and I implemented audio analysis using FFT. It displays your music using different visualizations and color schemes and can control up to 180 LEDs.
My approach uses a direct 3.5mm input jack. I did not amplify the input signal, but instead allowed the user to adjust the analog reference voltage with a pot marked "sensitivity". So if your music device has a weaker signal, you can increase the sensitivity by lowering the analog reference, and it also lowers the voltage on the high end of the input bias voltage divider. This approach works very well.
It also works well with an electret microphone that has an amplifier on it (like the small breakout boards from Sparkfun, etc.). I included a 5V pad near the input jack for exactly this situation.
@nootropic Your project looks really cool and professional! However, since i want to use the strips with an app, the board wont do the trick there.
Plus it kinda takes the fun of coding and the awesome feeling when it finally works. For people who just want the finished project its cool to have that option.
For me (as stupid as it sounds) the way is a awesome part aswell, not just the goal.
About 2 days ago I finally got the needed parts and can now finally start the music part of the project. The app for android is functional, but needs some optimization. So I think ill be able to test out the final version of the project quite soon.
If anyone is intrested in the app feel free to msg me. Although it is no near done, the basics are there and are easy to customize.
Thanks again for all the help everyone!
Really awesome and nice people in this forum