Intel Edison: VU-meter

by mkarvonen in Circuits > Arduino

2282 Views, 23 Favorites, 0 Comments

Intel Edison: VU-meter

kansi.jpg
Arduino VU-meter

This is how to make a simple VU-Meter with Intel Edison or any Arduino board.

Discover the music in visual form. Let's begin...

Mobile users can find the video included from HERE!

Components

DSCN4638.JPG
DSCN4639.JPG

Basic components needed are LCD screen, Microphone and Arduino based board.

Optional is the shield that i will be using.

Connect the components to the board and start coding.

Coding

DSCN4640.JPG

Coding this kind of project can be a challenge. And i have been inspired by many same kind of project's.

First of all we should include library's and global variables for the components.

Also in here are the blocks that will be moving when sound level rises.

#include
#include "rgb_lcd.h"

rgb_lcd lcd;

const int colorR = 255; const int colorG = 0; const int colorB = 255;

#define MIC 0

int colors;

#define T_REFRESH 100 // Refresh rate #define T_PEAKHOLD 4*T_REFRESH // Hold the peak

byte fill[6]={ 0x20,0x00,0x01,0x02,0x03,0xFF }; byte peak[7]={ 0x20,0x00,0x04,0x05,0x06,0x07,0x20 }; int lmax[2]; int dly[2]; byte block[8][8]= { { 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10 }, // character to fill the bar { 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18 }, { 0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C }, { 0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E },

{ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08 }, // character to peak level { 0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04 }, { 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02 }, { 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01 }, };

Then is time for setup.

I have included a small intro in here that will go through colors of the screen for a few seconds. Just for fun.

void setup ( void )
{ lcd.begin( 16,2 ); for( int i=0 ; i<8 ; i++ ) lcd.createChar( i,block[i] ); lcd.setRGB(colorR, colorG, colorB); lcd.setCursor(0,0); lcd.print("VU-Meter"); lcd.setCursor(0,1); lcd.print("mkarvonen"); delay(1000); lcd.setRGB(250, 105, 0); // Yellow delay(1000);

lcd.setRGB(250, 40, 0); // Orange delay(1000);

lcd.setRGB(255, 0, 0); // Red delay(1000);

lcd.setRGB(10, 10, 255); // Blue delay(1000);

lcd.setRGB(255, 255, 255); // white delay(1000);

lcd.setRGB(200, 0, 255); // Purple delay(1000);

lcd.setRGB(0, 255, 0); // Green delay(1000);

lcd.setRGB(255, 0, 100); // pink delay(1000); }

long lastT=0;

Then is time for loop that will go on and on forever.

void loop ()
{ if( millis()

bar( 0,anL ); lcd.setCursor(0,1); lcd.write("Beat this"); lcd.setCursor(10,1); lcd.write(0b11001101); lcd.write(0b01001111); lcd.write(0b01011111); lcd.write(0b01101111); lcd.write(0b00101111);

}

This is the important bit of the subroutine. This is the main thing that will define the sound bar on the screen.

void bar ( int row,int lev )
{ lcd.setCursor( 0,row ); lcd.write( row ? : 'B' ); for( int i=1 ; i<16 ; i++ ) { int f=constrain( lev -i*5,0,5 ); int p=constrain( lmax[row]-i*5,0,6 ); if( f ) lcd.write( fill[ f ] ); else lcd.write( peak[ p ] ); } if( lev>lmax[row] ) { lmax[row] = lev; dly[row] = -(T_PEAKHOLD)/T_REFRESH; } else { if( dly[row]>0 ) lmax[row] -= dly[row];

if( lmax[row]<0 ) lmax[row]=0; else dly[row]++; } }

Downloads

Test It and Fine Tune If Needed.

DSCN4641.JPG
DSCN4642.JPG
DSCN4643.JPG
DSCN4636.JPG
DSCN4644.JPG

Testing is a important part of the coding.

It should work right out of the box but who knows for sure.

If you need any assistance just ask!

Done.

DSCN4645.JPG
DSCN4647.JPG

Blast off yer speakers for this but remember that neighbors may not think that this project is a good idea.

Anyway thanks for reading and i hope that you will follow me for more awesome projects.

Happy building's!