diyAudio

diyAudio (http://www.diyaudio.com/forums/)
-   Analog Line Level (http://www.diyaudio.com/forums/analog-line-level/)
-   -   VU meter arduino project help (http://www.diyaudio.com/forums/analog-line-level/225888-vu-meter-arduino-project-help.html)

plasmaninjaa 17th December 2012 04:43 PM

VU meter arduino project help
 
Hello, I have been trying to finish the VU meter project found in the 30 arduino projects for the evil genius book.

I have followed it to the best of my abilities, but for some reason it is not working.

The VU meter only lights up when I blow hard into the microphone or play loud music from my phone directly overtop, and even then it doesnt seem to be very in sync with the music. Its as if it refreshes only every half second.

When there is no noise at all, the VU meter sits at the first bar, and even stays there when I shout from a distance.

-here is the project from the book: http://i50.tinypic.com/23k3gy1.png
- here is the code copied from the book:

int ledPins[] = {3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
int switchPin = 2;
int soundPin = 0;
boolean showPeak = false;
int peakValue = 0;
void setup()
{
for (int i = 0; i < 10; i++)
{
pinMode(ledPins[i], OUTPUT);
}
pinMode(switchPin, INPUT);
}
void loop()
{
if (digitalRead(switchPin))
{
showPeak = ! showPeak;
peakValue = 0;
delay(200); // debounce switch
}
int value = analogRead(soundPin);
int topLED = map(value, 0, 1023, 0, 11) - 1;
if (topLED > peakValue)
{
peakValue = topLED;
}
for (int i = 0; i < 10; i++)
{
digitalWrite(ledPins[i], (i <= topLED || (showPeak && i == peakValue)));
}
}

here is a overhead view of my circuit: http://i45.tinypic.com/2zfqu5s.jpg
side view: http://i49.tinypic.com/15ews35.jpg
computer screen: http://i46.tinypic.com/wukuf8.jpg

I printed out the values coming from the input of the mic, they hover around 140-150 no matter what, even if I tap the microphone. they only change when I blow into the mic or play loud music directly on top of it. And even then, they dont really go with the music... sometimes they go really low.

So I'm not sure what I did wrong, I followed the instructions as best as I could and I'm pretty sure I did everything right.
The transistor is a BC548-4 30v 100ma transistor, the cap is 10nf film rdl...


does anyone know where I went wrong?


Thanks!

linuxworks 22nd December 2012 02:37 AM

test your a/d circuit with a simulator. a pot with one end to vcc, one end to gnd and wiper to the a/d arduino input pin. run your 'print' debug program and vary the pot from end to end. do you read values? are they stable?

also, you should multiread and average to get better readings.

tauro0221 22nd December 2012 04:32 AM

Hi,
Check the voltage coming from the transistor to the input port #0 in the micro. Normally the input range for the A/D it is 0 to 5 volts and the micro will convert it to 0 to 1023 counts. So each count would be 5 / 1023 = .0049mv.

plasmaninjaa 22nd December 2012 02:03 PM

it turns out the diode was backwards. very strange since i thought the black line was the cathode on most diodes


All times are GMT. The time now is 05:30 PM.


vBulletin Optimisation provided by vB Optimise (Pro) - vBulletin Mods & Addons Copyright © 2014 DragonByte Technologies Ltd.
Copyright 1999-2014 diyAudio


Content Relevant URLs by vBSEO 3.3.2