After blinking an LED and mixing the colors in an RGB one, another popular beginner's circuit is an analog volume meter.
In mid-2008, joe published his excellent instructable showing how to build a VU meter on a breadboard using an LM3916, a 10-segment LED bar graph, a few resistors and capacitors, and a line-in jack. The secret sauce is the LM3916, an integrated circuit that senses analog voltage and drives 10 LEDs in proportion to the strength. (There are actually three flavors of this chip, with the LM3914 measuring voltage linearly, the LM3915 measuring voltage logarithmically in 3dB increments, and the LM3916 also measuring logarithmically, but with steps centered around 0dB at the traditional VU meter marks.)
If you hook an iPod and an LED bar graph to an LM3916, you'll have an LED display that dances up and down in response to the music's volume. I wanted one with a built-in microphone so I could watch the LEDs bounce without hooking up a headphone splitter, or better, watch it respond to the sound of people talking, dogs barking, or a dishwasher running.
The extra challenge is that the microphone's output is so tiny it has to be boosted and processed before sending it to the LM3916, which gave me an excuse to practice working with op-amps.
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Breadboard the Circuit
5K Trim Pot (used as a rheostat)
Resistors (100, 1K, 2K2, 10K, 22K, 100K)
Capacitors (.1u, 1u, 10u)
I find the key to enjoying breadboarding is to have a large breadboard with plenty of space in all directions. I start by placing the main components in the center and building out. As you can see from the short purple wires, the LM3916 chip is designed to hook directly to an LED bar graph. I laid those out first and then wired an iPod's headphone jack to the LM3916 to make sure the LEDs responded correctly. I then attached the 5K POT to adjust the sensitivity and a slide switch to toggle display modes - the LM3916 can show either a single dot for the volume or the LEDs below that dot for a bar graph.
Once that was working, I put the microphone and dual-channel op-amp in and started playing with various resistor and capacitor values until the mic provided a signal that drove the LEDs in the same way.
Step 2: Theory
Feel free to skip this section. This is information I picked up researching and tinkering with this circuit. It primarily comes from Byron J.'s excellent Sound Detector Hookup Guide.
The electret microphone contains a tiny capacitor attached to a JFET that creates an extremely small change in voltage in response to changing air pressure (sound waves).
The first part of the circuit is a 2.2K resistor in series with the microphone. (I've seen this resistor vary from 1K to 10K, with larger values making the microphone more sensitive, but 2.2K seemed to work best for the ambient levels in my home and garage.) The output is fed into a 10uF capacitor, which removes the DC component of the signal, i.e. centers it around 0 volts. The signal is fed through a 1K resistor into the inverting input of an op-amp. The op-amp has a 100K resistor between its output and that input, which makes it amplify the signal by 100K/1K = 100 times (40dB). There is a voltage divider on the non-inverting input so that the output is now the sound wave centered around 4.5V with a magnitude 100 times larger than the microphone's output.
The next step is to track the peaks of the signal, also known as following its envelope. That way, the LEDs show a graph of the volume changing over time, rather than simply rising and falling as the sound wave swings from positive to negative. To make the envelope follower, the signal is run through a 1uF capacitor to again center it around 0 volts, and then into the inverting input of another op-amp (the LM358 luckily contains two!) This time there is a diode between the output and input pins, which essentially cancels the negative half of the input signal. There is a 10K resistor before the input and a 22K resistor in parallel with the diode, so this second op-amp is also amplifying the signal by 2.2 times. (Actually, negative 2.2 times since this an inverting amplifier, but so was the first one, so this reverses the first flip. And sound is symmetrical so neither inversion should matter.)
When the output of this second op-amp swings high, a second diode (D2) turns on, and charges a 10uF capacitor (C5). When the op-amp output is high or not swinging, D2 is turned off, and C5 discharges through R9. C5 thus tracks the peaks of the input signal, and is fed into the LM3916.
The LM3916 turns on 0 to 10 LEDs depending on the input voltage, which is compared against its internal voltage ladder. I attached a 5K rheostat (variable resistor) to the 3916's adjustment pin so that the sensitivity can be changed to match the ambient sound level.
Step 3: Etch & Drill
Once the circuit worked consistently on a breadboard, it was time to transfer it to a permanent printed circuit board.
A year ago I wrote a GeekDad post detailing my process for making circuit boards at home, but basically I print the design from Eagle onto Pulsar Pro FX'sToner Transfer Paper and then laminate it directly onto a plain copper board. I etch the board by rubbing it with a sponge soaked in ferric chloride for a minute or two, dip it in liquid tin for another minute or two, then drill all the tiny holes using a Dremel drill press.
I then move each component from the breadboard to the PCB and solder it in place. Finally, I attach a 9-volt battery to the back of the board with velcro, and use the other switch to turn it on and off.
The end result is a a small, portable toy that shows the ambient noise level wherever I take it. My 4-year-old daughter likes to talk or sing to it and watch the lights move in response to her voice.