led vu meter somewhat.

so i’ve had my arduino for about 3 months, and I don’t know what i would do with out this forum.

this is my little vu meter… kind of. it takes serial data from winamp and a big thanks goes to macegr for the winamp plug in code and helping me out.

the volume is a little low on the vids.

this one is using old code, which has been redone.

Arduino code.

const int ledPin = 3;    
const int ledPin2 = 4;
const int ledPin3 = 5;
const int ledPin4 = 6;    
const int ledPin5 = 7;
const int ledPin6 = 8;
const int ledPin7 = 9;    
const int ledPin8 = 10;
const int ledPin9 = 11;
void setup()
{
  
  Serial.begin(57600);
  pinMode(ledPin, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  pinMode(ledPin3, OUTPUT);
  pinMode(ledPin4, OUTPUT);
  pinMode(ledPin5, OUTPUT);
  pinMode(ledPin6, OUTPUT);
  pinMode(ledPin7, OUTPUT);
  pinMode(ledPin8, OUTPUT);
  pinMode(ledPin9, OUTPUT);
}

void loop() {

 int lvl;
 int start = 100;   // start value from 255 for start range (fine tune lvls)
 //------------------------------------------------------------
 int total = 0;    // for calculations below. <<don't edit>> 
 int data[9];      // raw serial data <<don't edit>> 
 int value[10];    // values for the led pins based on the minus value <<dont' edit>>
 int check = 0;

// int last[9];
// int off = 0;
 // serial data start ---------------
  if (Serial.available() >10) {
    
     byte i = Serial.read();
     if (int(i) == 255) {
       for (int c = 0; c < 9; c++){
       data[c] = int(Serial.read());
       check = 1;
       }
//    
//      if (last[0] == data[0] && last[1] == data[1] && last[2] == data[2] && last[3] == data[3] && last[4] == data[4]){
//       off = 1;
//      } 
     }

  }

    

  // serial data end -----------------
  // some math -------------
 total = (255 - start) / 9;
 value[0] = 0;
 value[1] = start;
 for (int k = 2; k <= 8; k++){
   value[k] = value[k - 1] + total;
 }

//lvl = (data[0] + data[1] + data[2] + data[3] + data[4] + data[5] + data[6] + data[7] + data[8]) / 9;
lvl = (data[0]  + data[2]  + data[4] + data[6] + data[8]) / 5;
// math end -----------------


//---- single led ------
/*if (check == 1){
  if (lvl >= start){
    int val = map(lvl, start, 255, 5, 255);
  analogWrite(ledPin, val);
  }
  if (lvl < start){
    analogWrite(ledPin, 5);
  }

*/
// single led end -------------

 //----------- solution 1 ---------------- 
  if (lvl == 0){
    analogWrite(ledPin, 0);
    analogWrite(ledPin2, 0);
    analogWrite(ledPin3, 0);
    analogWrite(ledPin4, 0);
    analogWrite(ledPin5, 0);
    analogWrite(ledPin6, 0);
    analogWrite(ledPin7, 0);
    analogWrite(ledPin8, 0);
    analogWrite(ledPin9, 0);
  }
  if (lvl > value[0] &&  lvl <= value[1]) {
    analogWrite(ledPin, 220);
    analogWrite(ledPin2, 0);
    analogWrite(ledPin3, 0);
    analogWrite(ledPin4, 0);
    analogWrite(ledPin5, 0);
    analogWrite(ledPin6, 0);
        analogWrite(ledPin7, 0);
    analogWrite(ledPin8, 0);
    analogWrite(ledPin9, 0);
    
  }
  if (lvl > value[1] && lvl < value[2]) {
    analogWrite(ledPin, 220);
    analogWrite(ledPin2, 220);
    analogWrite(ledPin3, 0);
    analogWrite(ledPin4, 0);
    analogWrite(ledPin5, 0);
    analogWrite(ledPin6, 0);
        analogWrite(ledPin7, 0);
    analogWrite(ledPin8, 0);
    analogWrite(ledPin9, 0);
  }
  if (lvl>= value[2] && lvl< value[3]) {
    analogWrite(ledPin, 220);
    analogWrite(ledPin2,220);
    analogWrite(ledPin3, 220);
    analogWrite(ledPin4, 0);
    analogWrite(ledPin5, 0);
    analogWrite(ledPin6, 0);
        analogWrite(ledPin7, 0);
    analogWrite(ledPin8, 0);
    analogWrite(ledPin9, 0);
  }
  if ( lvl>= value[3] && lvl<=value[4]) {

    analogWrite(ledPin, 220);
    analogWrite(ledPin2, 220);
    analogWrite(ledPin3, 220);
    analogWrite(ledPin4, 220);
    analogWrite(ledPin5, 0);
    analogWrite(ledPin6, 0);
        analogWrite(ledPin7, 0);
    analogWrite(ledPin8, 0);
    analogWrite(ledPin9, 0);
  }
    if ( lvl>= value[4] && lvl<=value[5]) {

    analogWrite(ledPin, 220);
    analogWrite(ledPin2, 220);
    analogWrite(ledPin3, 220);
    analogWrite(ledPin4, 220);
    analogWrite(ledPin5, 220);
    analogWrite(ledPin6, 0);
        analogWrite(ledPin7, 0);
    analogWrite(ledPin8, 0);
    analogWrite(ledPin9, 0);
  }
    if ( lvl>= value[5] && lvl<=value[6]) {

    analogWrite(ledPin, 220);
    analogWrite(ledPin2, 220);
    analogWrite(ledPin3, 220);
    analogWrite(ledPin4, 220);
    analogWrite(ledPin5, 220);
    analogWrite(ledPin6, 220);
        analogWrite(ledPin7, 0);
    analogWrite(ledPin8, 0);
    analogWrite(ledPin9, 0);
  }
      if ( lvl>= value[6] && lvl<=value[7]) {

    analogWrite(ledPin, 220);
    analogWrite(ledPin2, 220);
    analogWrite(ledPin3, 220);
    analogWrite(ledPin4, 220);
    analogWrite(ledPin5, 220);
    analogWrite(ledPin6, 220);
        analogWrite(ledPin7, 220);
    analogWrite(ledPin8, 0);
    analogWrite(ledPin9, 0);
  }
    if ( lvl>= value[7] && lvl<=value[8]) {

    analogWrite(ledPin, 220);
    analogWrite(ledPin2, 220);
    analogWrite(ledPin3, 220);
    analogWrite(ledPin4, 220);
    analogWrite(ledPin5, 220);
    analogWrite(ledPin6, 220);
        analogWrite(ledPin7, 220);
    analogWrite(ledPin8, 220);
    analogWrite(ledPin9, 0);
  }
      if ( lvl>= value[8] && lvl<=value[9]) {

    analogWrite(ledPin, 220);
    analogWrite(ledPin2, 220);
    analogWrite(ledPin3, 220);
    analogWrite(ledPin4, 220);
    analogWrite(ledPin5, 220);
    analogWrite(ledPin6, 220);
        analogWrite(ledPin7, 220);
    analogWrite(ledPin8, 220);
    analogWrite(ledPin9, 220);
  }
 
}

cheers,
Dave Johnson

Got a code for the winamp plugin?

I got the code from macegr so I hope it's ok to post it.. he gave me this link to download the source files..

http://www.macetech.com/wa502_sdk.zip

I haven't changed much from his version, mostly because i have a hard time understanding how all of it works..

hi SilverCG
Could you post somwhere that plugin ? i tried to modify sources but it’s not working…
Thank’s a lot !