Thursday, December 12, 2019

How VU meter works?

I meet a cool classmate name Tri who major in CS and wants to program a microcontroller. I'm just a noob in a microcontroller world but I love to explore new things.
We come up with an idea, making a VU with Christmas light.

After looking at other projects, I realize that a microcontroller will read AC signal from an output source, then it will separate the voltage into each level and display them accordingly.

Let's look at a snippet from Instructable(1):
else
    {
      for (i = 0; i < input; i++)
      {
        digitalWrite(led[i], HIGH);
        delay(4);
      }
      for (i = i; i < 11; i++)
      {
        digitalWrite(led[i], LOW);
      }
    } 

In the above code, maxInput is 12. Whenever there is a signal, LEDs that are less than the threshold will turn ON. Then, they will be set back to OFF.

Another example from Instructable(2):

GreatScott uses an analog approach.
  1. Audio (AC) is the main input source (1.3V).
  2. Create threshold values for 7 rows.
  3. So we use LM324 opamp to amplify the signal from 1.3V to 8V.
  4. Then, we build 7 comparators using the same type of opamp.
  5. Then we use MOSFET as a switch
  6. Control by using V_GS