LED Audio Visualizer

From Makerpedia
Jump to navigation Jump to search

by Elise Knutsen


Project Overview

Description:

Have you ever wanted to ‘see’ music? An audio visualizer allows you to light up different LEDs based on the frequency of an audio input. This project uses filters (called band-pass filters) that isolate different frequencies of E-M waves in order to see how high or low a certain audio frequency is. If the music or sound being played is high or low, a different LED will light up. Because audio waves are longitudinal, they need to be converted into transverse EM waves using a microphone. Then, we can amplify the signal coming out of the microphone, send that to three different filters, and send the output of those different filters to an LED.


Tools and Materials

  • 1) 7 Op-Amps
  • 2) 1 npn transistor
  • 3) 1 electronic microphone
  • 4) 0.01 μF capacitors (4)
  • 5) 1 μF capacitors (8)
  • 6) 0.1 μF capacitors (2)
  • 7) LEDs (at least three, can also be fun to have more and multicolored)
  • 8) 50 Ω resisters (3)
  • 9) 5 kΩ resisters (2)
  • 10) 1 kΩ resisters (7)
  • 11) 200 Ω resisters (2)
  • 12) 2 kΩ resisters (2)
  • 13) 100 kΩ resisters (2)
  • 14) 10 kΩ resisters (2)
  • 15) 20 kΩ resister (1)
  • 16) DC power Supply
  • 17) Function Generator for testing
  • 18) Oscilloscope for Testing
  • 19) Misc. materials (breadboard, wires, cables, DMM, etc.)


Step-by-Step Instructions

Start by creating your filters. I initially thought that the visualizer would need a high-pass, low-pass, and band-pass (filter with a high and low limit). However, after testing the signal with audio, it became apparent that all the filters were going to need to be band-pass. Because humans can only detect sounds from about 20 Hz to 20 kHz, we do not want a low-pass filter to light up if there is a 10 Hz inaudible signal, or a high-pass filter to light up if there is a signal above 20 kHz. This ends up being an issue because the low pass filter can light up for a small DC offset, and the high pass can pick up inaudible high frequency noise from the environment. To make band-pass filters, you must connect the output of a high-pass filter to the input of a low-pass filter, or vice-versa. Although you could use a simple RC high-pass or low-pass filter, I decided to use a Sallen-Key filter. A schematic of a Sallen-Key high pass and low pass filter are on these sights: High-Pass filter (attached as Sallen-Key High Pass) http://sim.okawa-denshi.jp/en/OPseikiHikeisan.htm Low-Pass Filter (attached as Sallen-Key Low Pass) https://en.wikipedia.org/wiki/Sallen%E2%80%93Key_topology The only difference between a high pass and low pass Sallen-Key filter is the placement of the resistors and capacitors, mirroring the difference between high and low pass simple RC filters. However, the Sallen-Key filter uses two resistors and two capacitors to achieve more accuracy in the cutoff frequency, so it is called a second-degree filter. In addition, it includes a non-inverting amplifier, making it an active component, as an op-amp is an active component. The op-amp creates a voltage controlled voltage source, or a voltage output that is only proportional to the voltage going through it, making the filter more stable, as it is not vulnerable to changes in current. The rails of the op-amp should be powered with 15 V and -15 V and grounded. The equation to get the cut-off frequency if C2 and C1 are the same and R2 and R1 are equal, the cutoff frequency is: fc=1/(2πRC) Therefore, if we do not want a frequency above or below a certain level, we can set the cutoff frequency to that value to figure out what value of capacitors or resistors we will need. Below is a schematic of a band-pass Sallen-Key filter, where the output of the high-pass filter goes into the low-pass filter (attached as Sallen Key Band Pass). First band-pass filter—lets high frequencies pass For the first filter, we want high frequencies only. We only want frequencies lower than 20,000 Hz, as that is the highest humans can hear, and I decided to set the lower bound at around 3000 Hz. Note, these cutoffs are not exact, and signals slightly smaller than 3000 will light up the LED more dimly. In order to get this frequency, I used two 5 kΩ resistors and two 0.01 μF capacitors to get a cutoff frequency of 3183 Hz. Then I connected it to a high pass filter, built with two 0.01 μF capacitors and two 1 kΩ resisters to get a max frequency of 16000 Hz. Second band-pass filter—lets mid-range frequencies pass For the second filter, we want mid-range frequencies. I decided to build a low-pass filter that allows frequencies under 800 Hz by using two resistors with a resistance of 200 Ω and two 1 μF capacitors. For the high pass filter, I want a cutoff frequency of around 200 Hz, so I used two 1 kΩ resistors and two 1 μF capacitors. Third band-pass filter—lets low-range frequencies pass For the third filter, we want low frequencies only. For the low pass component, I used two 1 μF resistors and two 1 kΩ resisters to get a cutoff frequency of about 160 Hz. For the high pass component (to prevent a DC offset from always turning this light on once audio is connected), I used two 2 kΩ resistors and two 1 μF capacitors to get a cutoff frequency of 79 Hz Frequencies lower than 79 Hz still pass through, keep in mind, so this is a good way of making sure no frequencies less than 30 Hz will pass through, as 79 Hz is slightly bigger than 30 Hz.

After you are done building your filters, you should check them on an oscilloscope to make sure they behave properly. You should see a decreased signal when you are outside of the target frequency. After checking that your amplifiers work properly, you can add LEDs to see what happens. Connect the output of each of your filters to a 50 Ω resistor in series with an LED. You should see that as you adjust the frequency, different filter's LEDs light up. Different LEDs will have slightly different cutoff frequencies depending on the color. Experiment with colors to see with colors give the clearest distinction between the filters. At very low frequencies, you should see the LEDs flashing, as the frequency is not high enough to make the light appear continuous. Actually, the LEDs are always flashing but just so fast that your eyes can’t tell. You should also see that the light is dimmer when you are not in the peak range, as the amplitude of that signal is lower when not all of the signal is getting through due to a filter. If your filters work as expected, move onto step 3.

You are going to need a microphone if you want audio input to control your filters. The microphone will turn sound waves into EM waves that you can amplify and then send through the filters. I used a self-biased transistor circuit to connect to the microphone. A schematic is shown at the sight below (also attached as Self-biased transistor amplifier circuit in images). Self-biased transistor amplifier circuit: https://scienceprog.com/electret-condenser-microphone-amplifier-for-use-in-microcontroller-projects/ In order to get the required 3–9-volt input to go into the microphone, you can either use a voltage divider from your +15 V, or directly supply the voltage. I used a voltage divider (two resistors in parallel, with the output across one of the resisters). The self-biased transistor circuit works because the circuit output, coming out of the common collector side of the transistor scales based on how big the microphone output is. It also similar to a common-collector amplifier. Although this circuit will amplify the current to some extent (we will also need another amplifier) it will not cut out the DC offset. If we try to amplify the current again without cutting out the DC offset, we will not we are amplifying the audio signal that we want, but instead the DC offset. To remove the DC offset, I used a simple RC high pass filter with a resistor of 20 kΩ and a capacitor of 0.1 μF to get a cutoff frequency of 60 Hz (using the same equation as the Sallen-Key filter to calculate cutoff frequency). A circuit diagram for a basic RC high pass filter is at the sight below (also attached as Basic RC high pass filter). Basic RC high pass filter https://en.wikipedia.org/wiki/High-pass_filter Next, connected the output of your RC high pass amplifier into another amplifier, a non-inverting amplifier using an op-amp. A schematic is attached as Non-Inverting Op-Amp Amplifier. This filter uses negative feedback to amplify the current. I used -15 V and 15 V for the rails of the op-amp In order to get a gain of ~100, I used R1 =1 kΩ, and R2 =100 kΩ.. To can find the gain of a non-inverting amplifier using the following equation: Gain=R2 /R1 +1 Check to make sure you are getting a signal out of your amplifier when there is audio put into the mic (you may need to talk very close to the mic). If you are, you can connect the output of the amplifier to the input of the 3 filters (you will need 3 wires). Congrats, you have made an audio visualizer! Have fun having a dance party in your dorm room!