This week we make a simple VU meter using an Arduino.  We take audio input from either a microphone or a line level input and use a small transistor to amplify the signal, add some leds and some basic code to create a VU meter that has a switchable peak meter.

Downloads

HD Apple HD Apple SD Audio MP3

Sample Code

/*############### SAMPLE SIMPLE VU METER #########################
       This is sample code that takes a sample audio input signal and creates a very
basic VU Meter From: Mike Myers (http://mikemyers.me) @netnutmike Let's Make It Episode 23 (http://www.tech-zen.tv/episodes/shows/make-it-work/episodes/vu-meter-episode-23) http://tech-zen.tv For the sample code, show notes, contact information and many more videos, visit the show page at http://tech-zen.tv/letsmakeit Please subscribe to our YouTube channel or our netcasts at any of your favorite netcast / podcast outlets. We normally record Let's Make It live on Tuesday evenings around 7pm eastern. You can watch it live by going to tech-zen.tv and clicking the live link at the top of the page. We also have a community setup for our viewers and listeners. You can join the community by going to community.tech-zen.tv. We love input on what you would like to know or if you have an idea for a new Let's Make it episode, you can contact us via email or phone at the show information page. ################################################################################*/ int ledPins[] = {3,4,5,6,7,8,9,10,11,12}; int switchPin = 2; int soundPin = 0; boolean showPeak = false; int peakValue = 0; long lastPeak = 0; void setup() { for (int i=0; i< 10; i++) { pinMode(ledPins[i], OUTPUT); } pinMode(switchPin, INPUT); } void loop() { if (digitalRead(switchPin)) { showPeak = !showPeak; peakValue = 0; delay(200); } int value = analogRead(soundPin); int topLED = map(value, 0, 1023, 0, 11) -1; if (millis() > (lastPeak + 2000)) { peakValue = 0; } if (topLED > peakValue) { peakValue = topLED; lastPeak = millis(); } for (int i=0; i<10; i++) { digitalWrite(ledPins[i], (i <= topLED || (showPeak && i == peakValue))); } delay(50); }