Go Down

Topic: Help with LED VU Meter (Read 4436 times) previous topic - next topic

Techone

Quote
It require cap at the input. Initially, I thought just to post a link:
http://interface.khm.de/index.php/lab/experiments/arduino-realtime-audio-processing/
(I like this drawings, post it all the time).


@ Magician

Thank for the link. I will use it.

@ wally_z

What audio source you are using ? ( sound card ? IPOD ? Mp3 ? Cassette player ? )

Quote
Does hZ in electricity matter for this kind of thing? (hZ or Hertz, is electricity flowing through a wire, at all times, not sure about AC, the electricity is off for 60 times a second and on for 60 times a second. I guess AC is a bit slower than that to consider it AC.)


I am assumming you are from North America ( USA ? Canada ? ) AC is Alternating Current  A sound signal is also AC. Just the frequency is different. ( about 20 Hz to 15 000 Hz ) Correct me if I am wrong

Magician

Quote
Is there anything I have to change in schematic #3? Also, if I use a resistor of different resistance, will it decrease performance?
Sorry for confusing, actually 10 k is "optimum" value for #2. Just read data sheet again for zener, and all looks cool with leakage current 10 uA.
You don't have to change anything, but if you do, please, be advised that higher value for resistor in series with diode will attenuate input signal in #3.

wally_z

@Techone I am using my phone for audio output in mp3 format.

@Magician I realize now that AC has differing frequencies, and I guess DC is just 60Hz.

PaulS

Quote
and I guess DC is just 60Hz.

Guess again. Or do some research.

AC is alternating current. The frequency that it alternates at is important.

DC is direct current. Its frequency is infinite.

Magician

DC is constant current, or frequency = 0.
AC is alternating current with any frequency, except 0.
Audio signal usually considered to be AC with frequencies between 20 Hz - 20 kHz

AWOL

Quote
Its frequency is infinite.

Or even zero.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Techone

@wally_z

The audio signal from the phone need a DC level going into the analog pin.  ok

The top is a sine wave at 0 V line.

The bottom is a sine wave "running" at a DC line of 2.5 V.  You need a voltage divider.  47 K // 47 K should be fine.

Techone

@wally_z

And the code. Well from the examples files... here a LED graph display example. It use the map() function. You program did not include one. I hope you understand.  Make sure the audio signal is at proper level into the analog pin, it should be fine. I just hope your Aduino is still working.

Code: [Select]

/*
  LED bar graph

  Turns on a series of LEDs based on the value of an analog sensor.
  This is a simple way to make a bar graph display. Though this graph
  uses 10 LEDs, you can use any number by changing the LED count
  and the pins in the array.
 
  This method can be used to control any series of digital outputs that
  depends on an analog input.

  The circuit:
   * LEDs from pins 2 through 11 to ground

created 4 Sep 2010
by Tom Igoe

This example code is in the public domain.

http://www.arduino.cc/en/Tutorial/BarGraph
*/


// these constants won't change:
const int analogPin = A0;   // the pin that the potentiometer is attached to
const int ledCount = 10;    // the number of LEDs in the bar graph

int ledPins[] = {
  2, 3, 4, 5, 6, 7,8,9,10,11 };   // an array of pin numbers to which LEDs are attached


void setup() {
  // loop over the pin array and set them all to output:
  for (int thisLed = 0; thisLed < ledCount; thisLed++) {
    pinMode(ledPins[thisLed], OUTPUT);
  }
}

void loop() {
  // read the potentiometer:
  int sensorReading = analogRead(analogPin);
  // map the result to a range from 0 to the number of LEDs:
  int ledLevel = map(sensorReading, 0, 1023, 0, ledCount);

  // loop over the LED array:
  for (int thisLed = 0; thisLed < ledCount; thisLed++) {
    // if the array element's index is less than ledLevel,
    // turn the pin for this element on:
    if (thisLed < ledLevel) {
      digitalWrite(ledPins[thisLed], HIGH);
    }
    // turn off all pins higher than the ledLevel:
    else {
      digitalWrite(ledPins[thisLed], LOW);
    }
  }
}




Go Up