Hi Guys,
I am trying to make a LED cube that responds to bass, mid, and treble freqs. I am using 3 filters for my audio and feed them into 3 analog inputs of the arduino. As an amplifier, I am using a LM386 http://www.ti.com/lit/ds/symlink/lm386.pdf
The problem is (see schematic attached):
If there is no signal present, even then my analog input reads a steady value of around 512-1023 (seen in the serial monitor). It turns out that the value corresponds to the V+ supply to the LM386 and is half of V+, ie, just like the LM386 outputs a signal in the middle of the range 0-V+, it even does it for if there is no AC signal present. As a result of this, ALL my LEDs are on at all times, for the A0 reads off the value and it is well over the threshold for just the signals.
To avoid the problem, I introduced a capacitor ( C_ac_coup ) of around 100uF to act as a AC coupling device, but sadly it does not work. I could not figure out why.
Moreover, whenever I try to connect the GND of the arduino to the GND of my function generator (connected to wall outlet), my computer disconnects the arduino from the USB port. Does anyone know why?
I tried to correct the problem using mods in the code, but failed to.
Here is the code (it just does it for the bass at the moment):
int led[6] = { 3, 4, 5}; // Assign the pins for the leds
int leftChannel = A0; // left channel input
int left, i,left1;
void setup()
{
for (i = 0; i < 3; i++) // Tell the arduino that the leds are digital outputs
pinMode(led*, OUTPUT);*
Serial.begin(9600); // Uncomment to enable troubleshooting over serial.
}
void loop()
{
left= analogRead(leftChannel)-200;
Serial.println(left);
Serial.print("\t");// uncomment to check the raw input.
*left = left / 200; // adjusts the sensitivity *
Serial.println(left);
Serial.print("\t");// uncomment to check the modified input.
// left = 1500; // uncomment to test all leds light.
// left = 0; // uncomment to check the leds are not lit when the input is 0.
- if (left == 0) // if the volume is 0 then turn off all leds*
- {*
- for(i = 0; i < 3; i++)*
- {*
_ digitalWrite(led*, LOW);_
_ }_
_ }*_
* else*
* {*
* for (i = 0; i < left; i++) // turn on the leds up to the volume level*
* {*
_ digitalWrite(led*, HIGH);
}*_
* for(i = left; i < 3; i++) // turn off the leds above the voltage level*
* {*
_ digitalWrite(led*, LOW);
}
}
}
All I am trying to do with the code is to turn of a series of 3 columns of led depending on the strength of the signal (think of it as a volume meter of bass, etc. for each column).
Can anyone make it modifications to this code and/ or the HARDWARE to
a) take care of the DC bias
b) use a better calibration technique whereby I don't have to cardcode a calibration factor into it.
Really messed up now, guys. So any help will be appreciated.
proj.bmp (385 KB)*_