CrossRoads:
In Reply #15, you have the resistors shorted out - all 5 contacts in a row like that are the same connection.
The resistor needs to connect to 2 rows, such as 40 & 43, 55 & 58.
Where are the two 100K resistors per channel? Those are needed to set the 2.5V level after the signal goes thru the cap.
104 is a 0.1uF cap, you may lose some signal there, a larger value cap may be needed.
I WAS using a capacitor but multiple examples with the 3 pronged jacks didn't use capacitors.
With prior projects I did that so the signal(s) going from analog(s) can go through the resistor then through the wiring over the bridge to the channel(s). Or am I wrong here?
If you're not wired up like I showed in #5, with the two 100K resistors setting a 2.5V level at the analog input and the cap letting the AC part of the signal swing up & down from 2.5V (vs 0V out of your source), then you are wrong. That is called AC coupling, letting AC pass from one DC level to another DC level.
Arduino only wants to see 0-5V coming in. Your resistor might keep the current flow to where the input clamp diodes can clip the negative portion of the signal without blowing the diodes (so less than a mA or so), but that will yield crummy sounding audio coming in to be digitized.
I already pointed out your wiring was incorrect. The two leads of resistors and caps need to be in different rows, otherwise you are just shorting leads of a component together and may as well not even have them there.
CrossRoads:
If you're not wired up like I showed in #5, with the two 100K resistors setting a 2.5V level at the analog input and the cap letting the AC part of the signal swing up & down from 2.5V (vs 0V out of your source), then you are wrong. That is called AC coupling, letting AC pass from one DC level to another DC level.
Arduino only wants to see 0-5V coming in. Your resistor might keep the current flow to where the input clamp diodes can clip the negative portion of the signal without blowing the diodes (so less than a mA or so), but that will yield crummy sounding audio coming in to be digitized.
I already pointed out your wiring was incorrect. The two leads of resistors and caps need to be in different rows, otherwise you are just shorting leads of a component together and may as well not even have them there.
So working on it and i'm trying to think here. I think I have all the wiring very close to your diagram and explanation but have a quick question, wouldn't we need some sort of ground here?
Here's the code i'm using to run my arduino above
The pictures are below.
So essentially i'm just using 2 pairs(for each channel) of 2 LEDs . There are currently two blinking LED's, which are LED's 7 and 12. This means that the audio i'm testing is always between analog 820 and 1023 (based on my if statements) or i'm reading in the audio wrong (wiring).
Obviously i'm assuming that it's the wiring.
In addition, I think i'm going to have to use interrupts later on and that ran across my mind that it's possibly that i'm not using interrupts that could be the issue?
One thing i'm considering is the fact that I should just do what INTP said which is just use 3 prongs instead of all 5 because that's confusing the crap out of me. That way i'll be able to just follow other online demonstrations that used the normal 3 pronged audio inputs.
What's on the breadboard:
2 100K resistors
audio jack (5 prong)
Used the diagram that Crossroads attached to guide through the wiring
LED's with 330 ohm resistors
No extra power source, simply just USB right now. Didn't need extra power source,
though I did try and I could feel the voltage regulator heating up A TONNNN
When I unplug the audio source the lights on my arduino uno flicker for a few seconds then begin the sequence again. I've tried this with multiple audio device sources (computer, phone, ipod, mp3, you name it)!
CrossRoads:
The triangle under the lower resistor represents Ground. Connect it to the Arduino Gnd.
Quick to note:
When I unplug the audio source the lights on my arduino uno flicker for a few seconds then begin the sequence again. I've tried this with multiple audio device sources (computer, phone, ipod, mp3, you name it)!
So you take one single reading of the left channel and light up one LED based on its value, then wait 0.75 seconds before turning that LED off and then doing the same for the right channel.
You will be getting random values from the audio waveform. There's no relationship to the music loudness, pitch or anything. Imagine you're taking closeup photos of the loudspeaker while playing music - each photo will show the speaker in a different position, unrelated to any other photo.
MorganS:
So you take one single reading of the left channel and light up one LED based on its value, then wait 0.75 seconds before turning that LED off and then doing the same for the right channel.
You will be getting random values from the audio waveform. There's no relationship to the music loudness, pitch or anything. Imagine you're taking closeup photos of the loudspeaker while playing music - each photo will show the speaker in a different position, unrelated to any other photo.
Ahh okay okay so essentially analogread is literally returning values that are random completely. I wonder why they're random and have no relation to anything whether it may be pitch, volume, etc.
Main question: Would you have any potential guidance to send me in the path to organize those random values in a way that I can then look at tempo, pitch, volume etc?
Do you thin it'll be necessarily to have some sort of different interrupts in the future of this or no?
So he was right, they are completely random numbers being added in because I tested all random audio types.
Could there be something i'm doing wrong wiring wise or software wise? Every resource i've looked at read audio different ways but for the most part all either broke down 1-1023 to 0-255 or just sectored 1-1023 itself. I feel llike there's somethign wiring or software i'm doing that's not cutting it which results in it just constantly outputting 1002 to 1006
So i'm working on taking in audio through a small component and then display the audio levels through LED's based on volume, pitch...well in this case whichever is easiest to do since right now i'm reading in literally random values.
Well so, i'm essentially dealing with audio input through a 5-prong 3.5mm audio input component. Spec sheet:
Though I could've also wired it through only 3 of the prongs:
Anyway my pictures are below of my wiring and my code is below - in one of the pictures I removed the component so you can see the wiring a little better:
int lled[5] = {3, 4, 5, 6, 7}; // Assign the pins for the leds
int rled[5] = {8, 9, 10, 11, 12}; // Assign the pins for the leds
//delays are so the serial monitor isn't spammed by numbers and therefore i'll be able to catch them instead.
int leftChannel = 0;
int rightChannel = 1;
int left,right,i;
void setup()
{
for (i = 0; i < 5; i++)
{
pinMode(lled[i], OUTPUT);
pinMode(rled[i], OUTPUT);
}
Serial.begin(9600);
}
void loop()
{
left = analogRead(leftChannel);
Serial.println(left);
if (left == 0)
{
for(i = 0; i < 5; i++)
{
digitalWrite(lled[i], LOW);
}
}
else
{
if((left <= 205) && (left > 0))
{
digitalWrite(lled[0], HIGH);
delay(750);
}
if((left <= 410) && (left > 205))
{
digitalWrite(lled[1], HIGH);
delay(750);
}
if((left <= 615) && (left > 410))
{
digitalWrite(lled[2], HIGH);
delay(750);
}
if((left <= 820) && (left > 615))
{
digitalWrite(lled[3], HIGH);
delay(750);
}
if((left <= 1023) && (left > 820))
{
digitalWrite(lled[4], HIGH);
delay(750);
}
}
for(i = 0; i < 5; i++)
{
digitalWrite(lled[i], LOW);
}
right = analogRead(leftChannel);
Serial.println(right);
if (right == 0)
{
for(i = 0; i < 5; i++)
{
digitalWrite(rled[i], LOW);
}
}
else
{
if((right <= 205) && (right > 0))
{
digitalWrite(rled[0], HIGH);
delay(750);
}
if((right <= 410) && (right > 205))
{
digitalWrite(rled[1], HIGH);
delay(750);
}
if((right <= 615) && (right > 410))
{
digitalWrite(rled[2], HIGH);
delay(750);
}
if((right <= 820) && (right > 615))
{
digitalWrite(rled[3], HIGH);
delay(750);
}
if((right <= 1023) && (right > 820))
{
digitalWrite(rled[4], HIGH);
delay(750);
}
}
for(i = 0; i < 5; i++)
{
digitalWrite(rled[i], LOW);
}
}
The output i'm getting on the serial monitor is as follows:
1016
1012
1013
1013
1014
and so on and so forth going form 1008 (rare, usually from 1010) to 1018 (rare, usually to 1017)
I'm using 10K resistors. I tried using 100K but same result and I don't think 330 would be a good idea though i'm only using a 5V source straight from the arduino board so I wouldn't expect it to be a huge deal.
Someone on the forums recommended I used capacitors but that didn't do much so I removed them but that was before I went back down to 10K so that could be something to try again.
Whenever I unplug the wire (connecting the component to my audio source (this case my computer)) from the computer but not from the component it flat out goes to 1023 so that means when there is no audio source, it's 1023. Does this mean I need to include some sort of audio amplifier in my code to get a better read on the audio? I was looking at some of the arduino library and might try this out.
That being said, when I unplug the wire from the component but not the audio source (not that that part matters) it halts any output and have to re-upload the code or reset the board, though when I reset the board the lights flash but I don't get any serial output.
Hi,
What level of audio are you applying to the arduino analog inputs?
The analog input can only have 0 to +5V applied.
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
NOT a Fritzy picture but a diagram with pin numbers etc.
Have you tried connecting you A0 and A1 to gnd to check you get 0 and to +5V to get 1023 from your analogRead statements.
It looks like you have done a one big code write, then try to get it to work.
You should be coding in stages.
code analog input and get it working.
code LED display and get it working.
then combine and get it working.
Now please start at 1). remove the LED stuff and keep it lean and mean until you get the Audio read section working.
TomGeorge:
Hi,
What level of audio are you applying to the arduino analog inputs?
The analog input can only have 0 to +5V applied.
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
NOT a Fritzy picture but a diagram with pin numbers etc.
Have you tried connecting you A0 and A1 to gnd to check you get 0 and to +5V to get 1023 from your analogRead statements.
It looks like you have done a one big code write, then try to get it to work.
You should be coding in stages.
code analog input and get it working.
code LED display and get it working.
then combine and get it working.
Now please start at 1). remove the LED stuff and keep it lean and mean until you get the Audio read section working.
Tom....
I'm actually essentially not focused on the LED's right now. I've been reading in the analog input through the serial port to get it to work so i'm essentially still on 1). Yes i'm outputting to the LED's but I could very easily comment that out and just have the serial communication to look at the analog data!
Let me know and I will clarify ANYTHING.
I've been working on getting this to work for some time now and I frankly have no where else to go :(. Anyway I attached the image below:
Not sure if you can see the resistors but they are 10K as said before!
Okay so when I unplug the wire from the computer (but keep it plugged into the component) the serial data goes to 1023 flatout then when I plug it back in, the serial data goes to 1018-1020. Generally when you plug any audio devices to the computer it prompts you to choose where you want to audio to be output from the computer and when I select the audio output that I just plugged in (the wire), the serial data goes down to 1012-1016ish so it clearly reads that it's plugged in then it reads that its been chosen as the main audio output.
Also when I upload the arduino software to my arduino, it starts off at 1018-1019 then when I play any audio it goes to 1010-1011 then just stays around there for about 45 seconds then it gets back up to 1018-1019. It's obviously registering that it's reading in some sort of frequency but how do I get it to go from said 1010-1019 rather than staying 1010-1011 when hearing audio then 1018-1019 when not?
I'm sorry i'm asking so much ii've just looked everywhere and I don't know what I'm doing wrong
I've only been doing this for 5 months so i'm still a newbie and hard for me to really understand diagrams
I honestly thought I wired it up that way I'll rewire it 2 resistors per side (4 total)? I'll take a picture and attach below of what I'm understanding
The red wires going to 5V and the black wires going to GND
White wires going to a0 and a1
green wires and yellow wires going to the audio jack
OMYGOSH IT WORKS
thank you so much for pushing me to keep trying the diagram everyone thank you so much!!!
I'm actually getting values that correlate to the audio i'm playing. Only weird thing is i'm using 2 10K resistors and 2 100K resistors but i'm going to get 2 more 100K resistors tomorrow (they're locked up) and use those instead
Hi,
Good that its doing what you need, 10K or 100K is okay, 100K will mean your audio input will not be loaded as much as 10K would, so better audio with 100K.