Making the LPD8806 (and LED strip) go along with music?

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Making the LPD8806 (and LED strip) go along with music?

Postby phnxfirestorm » Tue Feb 14, 2012 6:25 pm

Is it possible ,without programming a sequence to follow a specific song, to make the LED strip go along with any music?
Like for instance, it would have a color display and move across the strip depending on how loud the music was.
I don't know how to explain it.
phnxfirestorm
 
Posts: 30
Joined: Wed Jan 18, 2012 9:28 pm


Re: Making the LPD8806 (and LED strip) go along with music?

Postby pburgess » Tue Feb 14, 2012 8:18 pm

You betcha. Google around for "spectrum analyzer", "color organ" and/or "vu meter" (and perhaps "Arduino" if that's your target platform). The Processing language also includes an audio library, if you're planning something computer-tethered.
User avatar
pburgess
 
Posts: 1339
Joined: Sun Oct 26, 2008 1:29 am

Re: Making the LPD8806 (and LED strip) go along with music?

Postby phnxfirestorm » Wed Feb 15, 2012 8:29 pm

adafruit_support wrote:There are a bunch of projects along those lines out there. Here's one: http://forums.adafruit.com/viewtopic.php?f=25&t=22087&p=115683


I was more of looking for something that was programable on the atmega32u4. or could be piped from the 32u4 to arduio uno (vise versa). Since those are the only things I have at the moment.
phnxfirestorm
 
Posts: 30
Joined: Wed Jan 18, 2012 9:28 pm

Re: Making the LPD8806 (and LED strip) go along with music?

Postby pounce » Thu Feb 16, 2012 6:47 am

You should really try using google or other search engines to try to find what you need based on the hints provided by the moderators and kind Sr members of this forum.

Try adopting the example at tinyurl.com/vumeter to use your LED strip instead of the output pins.

Realize that you will need to code and you will need to decide for yourself what the LED's should do and how they should do it based on what you are getting from the inputs.

It will be fun if you chose to take the time to learn and understand how to interact with inputs. If you find yourself hitting a brick wall you could consider some of the many books on the topic. Also, there is this forum plus many others that help people with using Arduino.
pounce
 
Posts: 82
Joined: Wed Nov 23, 2011 5:36 pm

Re: Making the LPD8806 (and LED strip) go along with music?

Postby phnxfirestorm » Mon Feb 20, 2012 6:01 pm

pounce wrote:You should really try using google or other search engines to try to find what you need based on the hints provided by the moderators and kind Sr members of this forum.

Try adopting the example at tinyurl.com/vumeter to use your LED strip instead of the output pins.

Realize that you will need to code and you will need to decide for yourself what the LED's should do and how they should do it based on what you are getting from the inputs.

It will be fun if you chose to take the time to learn and understand how to interact with inputs. If you find yourself hitting a brick wall you could consider some of the many books on the topic. Also, there is this forum plus many others that help people with using Arduino.


I was looking for hints on how to do it with just the LED strip and my atmega32u (Plus a mic.)
phnxfirestorm
 
Posts: 30
Joined: Wed Jan 18, 2012 9:28 pm

Re: Making the LPD8806 (and LED strip) go along with music?

Postby elmerfud » Mon Feb 20, 2012 10:22 pm

This thread had caught my interest when it was first posted as I was interested in doing something similar. I've found that pretty much everything that's needed, at least in a generic sense, to make it work has been posted.

The link that adafruit_support posted shows a diagram to make an offset circuit so you can use your mic with the analog input. It's a cap and a few resistors. There are other examples, if you google around, that use a potentiometer which is likely a bit better because then you can tune the offset as needed for your input source. It also has fft functions which can perform beat detection. I guess what's left is just changing the output to be able to light up the LPD8806.

Depending on what you mean when you say "go along with music" it can be a whole lot simpler. If you're not concerned about beat detection and just want fixed patterns to start/stop depending on music or noise level then you can just use the input circuit and wedge in some code to read the analog input. Once it detect noise then have it start running its pattern loop.
elmerfud
 
Posts: 20
Joined: Wed Feb 01, 2012 5:28 pm

Re: Making the LPD8806 (and LED strip) go along with music?

Postby thad » Tue Feb 21, 2012 7:01 am

thad
 
Posts: 1
Joined: Tue Feb 21, 2012 6:57 am

Re: Making the LPD8806 (and LED strip) go along with music?

Postby pounce » Tue Feb 21, 2012 9:26 am

I think the OP is probably just looking to plug something into his LED belt kit and then upload some code and head off to school. I'm not sure they are ready for non kit solutions just yet. Nothing wrong with that. Adafruit might want to consider an add-on pack for the LED belt that adds a shield with a mic to add vumeter effects. VUmeters have come up in several recent threads and I think it's probably right there near the top of the list of things that are interesting to do with LED's and Arduino. Until then we'll have to see if the OP is hungry enough to build it or if there is another member generous enough to drop a complete step by step solution.
pounce
 
Posts: 82
Joined: Wed Nov 23, 2011 5:36 pm

Re: Making the LPD8806 (and LED strip) go along with music?

Postby pounce » Tue Feb 21, 2012 10:23 am

This shield would be very useful:

http://www.sparkfun.com/products/10306
pounce
 
Posts: 82
Joined: Wed Nov 23, 2011 5:36 pm

Re: Making the LPD8806 (and LED strip) go along with music?

Postby elmerfud » Tue Mar 06, 2012 2:01 pm

Here's the "color organ" Arduino code that's been modified to output to a WS2801 strip.

https://github.com/elmerfud/music_color

It's pretty much the same code and outputs in the same bar graph style.

http://www.youtube.com/watch?v=hKHM4GEJTRs (no audio on my video)

It uses the Adafruit WS2801 library, but changing it over to the LPD8806 library should be pretty simple. Just link in the other library, change the WS201's to LPD8806's and change the color levels from 255 to 127.

I'm by no means an FFT wizard (ok, I really know nothing about FFT magic math), but from what I understand this is more so measuring frequency component amounts. Of course I've been known to understand things wrong too.
elmerfud
 
Posts: 20
Joined: Wed Feb 01, 2012 5:28 pm

Re: Making the LPD8806 (and LED strip) go along with music?

Postby domorethanyoucan » Thu Mar 08, 2012 3:03 pm

Something quite a bit more simple, not a kit, and no sample code, but fairly trivial: https://www.sparkfun.com/products/9964

Three wires, read it like any other analog input.

I'm sure the audrino examples include reading from a potentiometer or something. Use that code and a pin of your choice to read from this thing instead. The pinouts on the controller are undocumented and unsupported, but for the one i received recently (and used the LED belt tutorial to program) they're pretty close to the same pins used on the teensy 2.0: http://www.pjrc.com/teensy/card2b.pdf

You'll have to figure out how to alter the brightness of your LEDs yourself. Going to have to dig into the code and figure that one out yourself. Maybe I'll buy a belt myself and play with it, but i've been a bit leery of bending that led strip constantly.
domorethanyoucan
 
Posts: 17
Joined: Tue Feb 21, 2012 8:52 pm

Re: Making the LPD8806 (and LED strip) go along with music?

Postby ScottishDave » Sun Apr 08, 2012 2:40 pm

I written something to do this - it tracks volume level and uses the wheel function to spread the colours across the strip. It is my first go at writing a proper sketch so would welcome any feedback. It should work on most Arduinos - I am using a nano.

Code: Select all
//"Make LED strip go with music" thingy - LED Volume Level Follower by Scottish Dave
//
// Uses code from Adafruit LDP8806 library (Wheel Function), Arduino example code
//(Smoothing) and various posts from the Arduino and Adafruit forums. Thanks to all the authors.

// Limitations / Issues
//
// It is not accurate - the maximum level fall per loop is limited - this prevents flicker and makes it look nicer.
// The sensor level is both mapped AND constrained. So it is not really a true reading.
// The Array size is a guess. Its way too large, and needs to be a calculated value. One day.
// Only tested using Dance music. I suspect it wont work too well with comples tunes

//All serial commands are commented out, they can be used to monitor sound levels
//and validate your input sensor.

#include "LPD8806.h"
#include "SPI.h"

// User Settings

LPD8806 strip = LPD8806(64, 2, 3);    // (number of LEDs, data pin, clock pin)

int inputPin = A7;                    // Mic/Sensor input Pin
int Sens = 250;                       // Limits range of sensor values. High = Less Sensitive
int Period = 15;                      // Amount of time, in milliseconds, to sample readings from the sensor.
int MaxDrop= -(strip.numPixels()/8);  // Limits the max amount the of LEDs that can be switched off in one Loop.
//int MaxDrop = -                     // Manual over-ride for max drop. Comment out statement above if you use this line.
int StartColour = 224;                // Colour of First, Lowest LED. A multiple of the number of Leds in your strip works best.
//int Step =12;                       // Manual over-ride for step parameter. This is the amount each step along the strip
                                       //moves DOWN the colour wheel

// These variables are used by the smoothing code. Taken from Arduino Smoothing example

const int numReadings = 400;          // // the size of the arrary for readings from the sensor
int readings[numReadings];            // the array for readings from the analog input
int index = 0;                        // the index of the current reading
int total = 0;                        // the running total

// These variables are used for Loop timing

unsigned long stime;                  // Start time of loop execution
unsigned long etime;                  // End time of loop execution

// These variables are used for writing to the strip

int Slvl;                                 // Starting Level, read from Sensor.
int Nlvl;                                 // New Level.
int diff;                                 // Difference between Start and New Level
int i;                                    // Loop Variable
int Step=StartColour/strip.numPixels();   // This is the amount each step along the strip moves DOWN the colour wheel


void setup() {

for (int thisReading = 0; thisReading < numReadings; thisReading++)
    readings[thisReading] = 0;          // initialize all the readings in the array to 0

if (strip.numPixels() > StartColour) { 
  StartColour = strip.numPixels();     // Ensure colours dont exceed wheel function limitations.
  Step=1; }

strip.begin();                          // Start up the LED Strip
strip.show();                           // Clear the Strip
//Serial.begin(9600);                   // Start serial connection
}

void loop() {
 
  // This section of the loop smooths the output from the mic. It reads output to from the sensor to an array and
  // calculates the average reading over a period of milliseconds
 
  stime = millis();                       // Sets loop start time
  etime = stime;

  while ((etime - stime) <= Period) {     // This is the loop that samples the audio. Measures loop start and end time against Period.
 
  total= total - readings[index];         // subtract the last reading:     
  readings[index] = analogRead(inputPin); // read from the sensor: 
  total= total + readings[index];         // add the reading to the total:   
  index = index + 1;                      // advance to the next position in the array:                   
  etime = millis(); }                     // Set loop end time.
             
  Nlvl = total / index;                                // calculate the average and set New Level   
  Nlvl = map(Nlvl, 0, Sens, 0, strip.numPixels());     // maps the output of the sensor to the number of pixels in the strip
  Nlvl = constrain(Nlvl, 0, strip.numPixels());        // You may get out of range values. This keeps values in range:
 
  //Serial.print("New Level = ");
  //Serial.println(Nlvl);
 
  index = 0;                              //Resets the array
  diff = Nlvl - Slvl;                     // The number of pixels to change
 
  //Serial.print("Diff =  ");
  //Serial.println(diff);
 
  // This section writes the new value to the strip. It uses the wheel code
  // from the Strandtest example included in the Adafruit LDP8806 Library.
 
  if(diff > 0) {                                 //If New Level is higher than the last, light strip from old level to new level
  for (i=Slvl; i <= Nlvl; i++) {
    strip.setPixelColor(i,Wheel(StartColour-(Step*i)));     
  }                                             
  strip.show();                                  // Write changes to the strip
  Slvl = Nlvl;                                   // Set the Starting Level to New Level
}
else if(diff >= MaxDrop && diff < 0) {          //If New Level is lower than the last AND greater than Max Drip, turn LEDs off
  for (i=Slvl; i >= Nlvl; i--) {
    strip.setPixelColor(i,strip.Color(0,0,0));
  }
  strip.show();                                  // Write changes to the strip
  Slvl = Nlvl;                                   // Set the Starting Level to New Level
}
else if(diff < MaxDrop) {                        // If Diff is lower than Max Drop, turn Max Drop number of LEDs off
  for (i= (Slvl + MaxDrop); i <= Slvl; i++) {
    strip.setPixelColor(i,strip.Color(0,0,0));
  }
  strip.show();
  Slvl = Slvl + MaxDrop;
  // Serial.println("Max Drop Max Drop Max Drop); 
}
//Serial.print("Starting Level = ");
//Serial.println(Slvl);
}

// This is wheel code from the Adafruit LDP8806 Strandtest example.

uint32_t Wheel(uint16_t WheelPos)
{
  byte r, g, b;
  switch(WheelPos / 128)
  {
    case 0:
      r = 127 - WheelPos % 128;   //Red down
      g = WheelPos % 128;      // Green up
      b = 0;                  //blue off
      break;
    case 1:
      g = 127 - WheelPos % 128;  //green down
      b = WheelPos % 128;      //blue up
      r = 0;                  //red off
      break;
    case 2:
      b = 127 - WheelPos % 128;  //blue down
      r = WheelPos % 128;      //red up
      g = 0;                  //green off
      break;
  }
  return(strip.Color(r,g,b));
}
ScottishDave
 
Posts: 7
Joined: Fri Mar 02, 2012 5:52 am


Return to Glowy things (LCD, LED, TFT, EL) purchased at Adafruit

Who is online

Users browsing this forum: mark79 and 7 guests

Stuff to buy from the Adafruit store and links to product documentation!


New Products [103]

Raspberry Pi[80]
 
FLORA[23]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[11]
Arduino[60]
 
NETduino[14]
 
BeagleBone[24]
 
Android[6]
 
XBee[10]
More Dev Boards[30]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[33]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[8]


 
Breakout Boards[33]
LCDs & Displays[48]
Components & Parts[69]
Batteries & Power[49]
EL Wire/Tape/Panel[52]
LEDs[109]
 
Wireless[14]
Cables[61]
 
Lasers[6]
Sensors/Parts[145]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[70]
 
iDevices[13]
Tools[71]
 
Wearables[39]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[24]


 
Stickers[41]
 
Skill badges[55]
 
Books[25]
 
Circuit Playground[7]
 
Gift Certificates[4]