Friday, September 28, 2012

VU Meter using Adafruits LED strip


I have made a VU meter using an ISP addressable LED strip. The project is made based on the project done by Jeremy Blum. See the video tutorial here. The rest of the his arduino series is excellent.

The electronics I have used are the same. This is a basic amplifier circuit that keeps only the peaks of the sinusoidal audio signal.

The code his tutorial produces gives a piece of code that has the LED change colour depending on the level of the audio output. The colour then moves down the LED strip at a fixed rate.

My code takes the signal level from the audio and converts it into a certain number of illuminated LEDs. Giving a VU meter effect. The code I used, which was barbarically adapted from Jeremy´s is below:


//Basic VU meter by Cameron Stewart http://hackingismakingisengineering.blogspot.com/2012/09/vu-meter-using-adafruits-led-strip.html
//Based on Jeremy Blum´s Design available at http://www.jeremyblum.com/2011/12/25/tutorial-14-for-arduino-holiday-lights-and-sounds/
//SPI Library
#include "SPI.h"
//Include Library for LED strip using Ada fruit´s library
#include
//Analog Audio Input Pins - from OPamp circuit.
int left_channel = 0;
int right_channel = 1;
//Light Control Pins
int light_data = 2;
int light_clk = 3;
//Setup Strip Constants
const int length = 32;
const int half = length;
//Creat strip object from Object Library
LPD8806 strip = LPD8806(length, light_data, light_clk);
//Initialise strip array.
uint32_t strip_array[length];
void setup()
{
  //Start serial for debugging
  Serial.begin(9600);
  //Fill pixel arrays with zeros
  for(int i=0; i  {
    strip_array[i] = 0;
  }
  //Initialize Strip
  strip.begin();
  strip.show();
}
void loop()
{
  //Uncomment this section to open the serial window for debugging
  //Serial.print("left:    ");
  //Serial.print(analogRead(left_channel));
  // Serial.print("right:    ");
  // Serial.println(analogRead(right_channel));
  //Determine power level
  int power = map(analogRead(right_channel), 0, 800, 0, 32);
  Serial.println(power);
  //Original Strand test function that came with the LED strip
  //colorChase(strip.Color(127, 127, 127), 10); // White

  //My new VU function
  uvMeter(strip.Color(127, 127, 127), power); // White
  //Display the new values
  strip.show();
  delay(0);
}
void uvMeter(uint32_t c, int pow) {
  int i;
  // Start by turning all pixels off:
  for(i=0; i // turn on all pixels below the peak level
  for(i=0; i<=pow; i++) strip.setPixelColor(i, c);

  // Display LEDs
  strip.show();
}
void colorChase(uint32_t c, uint8_t wait) {
  int i;
  // Start by turning all pixels off:
  for(i=0; i  // Then display one pixel at a time:
  for(i=0; i    strip.setPixelColor(i, c); // Set new pixel 'on'
    strip.show();              // Refresh LED states
    strip.setPixelColor(i, 0); // Erase pixel, but don't refresh!
    delay(wait);
  }
  strip.show(); // Refresh to turn off last pixel
}

After the first iteration I plan to add a few more features to the code to make the effect a little more tidy. Future improvmentes:

  • Dynamic ranging - to make use of the full LED strip.
  • Double/Triple sampling - to clean up the signal a bit
  • A top cap bar - similar to the effect in modern stereo VU meters
  • Stereo support 
  • Frequency filtering.



Thursday, September 20, 2012

Ada Fruit breadboard power supply

My package finally arrived from adafruit. The first thin I did was build up the breadboard power supply the breadboard in a little project box I have with an arduino. I plan to wire it up so the power supply will power the board when connected or, when using lower currents the board will run of the USB without powering the electronics on the supply circuit.

Any suggestions on how to do this without too much voltage drop??

A couple of negative things I would like to point out are: 
  • There are no holes in the PCB for mounting the device in a housing.
  • The heatsink is not well suited to the circuit layout because it clashes with the voltage regulator and screw terminals.

Sunday, September 2, 2012

Let's Build a Goddamn Tesla Museum

Donate to Tesla. I donotated enough for 3.3333 ghost high fives and haircut/moustache complements .

http://www.indiegogo.com/teslamuseum

Read theOatmeal comic!

Contribution Amount: $10

Perk: Tesla loves the number 3 (And if you donate $3, Tesla will love you too. If he were alive today he'd totally high-five you and compliment your haircut and/or mustache.)

Appearance: Visible Contribution - Your identity and amount will be public

Payment Method: via PayPal

My Embedded LEDs Have Been Featured on Instructables.com


My embedded /ɛmˈbɛdid; adj./ LED rim lights were featured on Instructables.com woohoo! to the left of the gunholster (don't let it distract you). It's my first instructable and the first thing I have done since I decided to document my projects. Win.
http://www.instructables.com/id/Inbedded-Bike-Rim-Lights/

Video in action here
http://youtu.be/hsXuLRNnScI