VU Meter- Earthling question.. i think?

Hello good peoples of Arduino: Forum

I, venturing into the vu world have had some sucess. lights turn on. though only when i touch the 1/4 ich jack with my fingers.. when its is plugged into an amp playing david bowie's Moonage Daydream i get nothing.

am using 5 leds to start with. a bread board and an arduino duemilanove.

if you have time and are able to help me to visualise david bowie up in lights on a busy workdesk i'd be very very grateful indeed

kind regards fellow fellows

stephen

here is the code i am using:

// these constants describe the pins. They won't change:
const int soundpin = 5; //reads the power from the light sensor
const int LED1= 2; //LED's 1-5 numbered accordingly
const int LED2= 3;
const int LED3= 4;
const int LED4= 5;
const int LED5= 6;

int sound[4];
int soundav;

void setup()
{
// initialize the serial communications:
Serial.begin(9600);

// Provide ground and power by using the analog inputs as normal
// digital pins. This makes it possible to directly connect the
// breakout board to the Arduino. If you use the normal 5V and
// GND pins on the Arduino, you can remove these lines.
pinMode(soundpin, INPUT);
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
pinMode(LED4, OUTPUT);
pinMode(LED5, OUTPUT);

}
void loop()
{
for(int num=0;num<4;num++)
{
sound[num]=analogRead(soundpin);
if(num==2)
{
soundav=(sound[0]+sound[1]+sound[2]+sound[3])/4;
if((soundav)>50)
{
digitalWrite(LED1,HIGH);
digitalWrite(LED2, HIGH); // set the LED on
digitalWrite(LED3,HIGH);
digitalWrite(LED4, HIGH); // set the LED on
digitalWrite(LED5,HIGH);

}
else if((soundav)>40)
{
digitalWrite(LED1,HIGH);
digitalWrite(LED2, HIGH); // set the LED on
digitalWrite(LED3,HIGH);
digitalWrite(LED4, HIGH); // set the LED on
digitalWrite(LED5,LOW);
}
else if(soundav>30)
{
digitalWrite(LED1,HIGH);
digitalWrite(LED2, HIGH); // set the LED on
digitalWrite(LED3,HIGH);
digitalWrite(LED4, LOW); // set the LED on
digitalWrite(LED5,LOW);
}
else if(soundav>20)
{
digitalWrite(LED1,HIGH);
digitalWrite(LED2, HIGH); // set the LED on
digitalWrite(LED3,LOW);
digitalWrite(LED4, LOW); // set the LED on
digitalWrite(LED5,LOW);
}
else if(soundav>10)
{
digitalWrite(LED1,HIGH);
digitalWrite(LED2, LOW); // set the LED on
digitalWrite(LED3,LOW);
digitalWrite(LED4, LOW); // set the LED on
digitalWrite(LED5,LOW);
}
else
{
digitalWrite(LED1,LOW);
digitalWrite(LED2, LOW); // set the LED on
digitalWrite(LED3,LOW);
digitalWrite(LED4, LOW); // set the LED on
digitalWrite(LED5,LOW);
}

}
}
Serial.print(analogRead(soundpin)); //output for serial monitor

Serial.println(" ");
delay(10);
}

Hi Stephen,
First off, lets make your project a little easier to follow.
Go back & modify your post, with before the code listing starts and after it ends. That will put it in a nice scrollable box.
Next, please describe the LED set up you have. The LED Anodes are connected from Ardiono pins 2,3,4,5,6 to current limit resistors (~300 ohm or so) to ground?

You have the amplifier output ground (the sleeve of the 1/4 jack) connected to the arduino ground, and the output itself (the tip) connected to analog pin 5?

What is the amplifier output? Can you look at it with an oscilloscope and confirm the voltage swing is large enough to be properly read?
A PC soundcard scope you can try is Virtual Analyzer

Some notes:

  1. Audio Line Level = +/- 0.447V Peak to Peak. (yes, that is Plus and Minus voltage... something the Arduino input does not want to see.)
  2. The Arduino input expects a voltage between zero and 5 volts for full scale reading.

When you TOUCH the input... you are creating a huge spike... that's why you might see it.

Things to try/research 1) Amplify 2) Use a comparator or Schmidt trigger 3) look at some frequency counter input circuits for ideas.

It will except - voltage if you bias the input.

Are aliens not allowed to answer this question then?

Is that a bit specist?

Hi
solved! and now another quesion..

firstly
Thanks for the code scrolling box tip; noted for the next time.

regarding resisters and what have you, my only materials are some solid wire, leds, breadboard and the arduino.

the leds are positioned over the devide of the breadboard, the negatives are connected to the outer negative side of the board and the positives to the digital outputs on the arduino.

__the model i'm using can be seen here http://www.instructables.com/id/VU-Meter/.

i have solved the problem, i think the levels were not high enough and i am now grounded on earth.

My next task is to figure out how to make consistent the intensity of the LEDs as they flicker from bright to not bright. the current i guess is unstable and i need to use some 'thing' to even out the curent levels to a constant that would result in a smoother output.

any ideas and thank you all for your support this really is new territory for me

PS: And of the aliens...
Of course! Only earthlings could understand the shape i'm in!

thanks

regarding resisters and what have you, my only materials are some solid wire, leds, breadboard and the arduino.

If you don't get some current limiting resistors, you may not have a working atmega chip in your mega for long, unless your LEDs have a built in resistor.

Regarding the flickering - you could likely address that with a software change that holds the LEDs on a little longer after being turned on. Right now you appear to be taking 4 samples, turning on/off the LEDs on the 2nd sample, you have a 10mS delay in there, so you are update once every 40mS, which would be like a 25Hz rate. Take out the delay, let it run faster.