Music and Lights – RGB strip driver

First of all, I made some changes to my project objectives. The music and lights system I am building will not be attached to my bicycle. This is because I don’t think it will be used that often if it is just on my bicycle. So instead I am gonna set it up on my room, so that I can make the most out of it.

So far I have build an amplifier for the speakers and a triple channel audio filter for the lights (see previous posts). The next step is to read the output values of the triple channel audio filter and drive the TM1809 RGB strip to represent those values. For this I am using an Arduino. I have several Arduino boards hanging around and they are great for when you need to write a simple program to read sensor data and do something with it. Also there is a fantastic library for Arduino called FastLED that makes driving LED strips a breeze.

So I wrote a simple program to read the output values of the triple channel filter and drive the RGB strip with the red, green and blue values representing bass, mid and treble levels.

   Purpose: Read three analog values and drive a TM1809 RGB strip with the red,
   green and blue levels representing the analog values. 

   @author Kasun Somaratne
   @version 1 06/07/14

#include <stdio.h>
#include <FastLED.h>

#define NUM_LEDS      30
#define DATA_PIN       7
#define BASS_PIN      A0
#define MID_PIN       A1
#define TREBLE_PIN    A2

//create an array of RGB values for the number of leds on the strip.

void setup()
  //Specify the led strip type and the data pin used to send data to the led strip
  FastLED.addLeds<TM1809, DATA_PIN>(leds, NUM_LEDS);

  //Initially turn all leds off
  for(int i = 0; i < sizeof(CRGB); i++)
     leds[i] = CRGB(0,0,0);

void loop()
  // read the bass, mid and treble values. These values will be between 0-1023.
  int bass = analogRead(BASS_PIN);
  int mid = analogRead(MID_PIN);
  int treble = analogRead(TREBLE_PIN);

  //calculate the number of LEDs to be lit using the bass value
  int litLEDCount = map(bass, 0, 1023, 0, NUM_LEDS);

  //map the bass, mid and treble values to red, green and blue values. The rgb values can only be from 0-255
  int rVal = map(bass, 0, 1023, 0, 255);
  int gVal = map(mid, 0, 1023, 0, 255);
  int bVal = map(treble, 0, 1023, 0, 255);

  //turn off all the LEDs on the array
  //update the LED strip with calculated red, green and blue values
  for(int i = 0; i < litLEDCount; i++)
    leds[i] = CRGB(bVal,rVal,gVal);
  //display the LEDs;


Finally, It is time to test the entire setup. Here’s a short video showing how it looks at the moment:

Not bad for the first try, right? However, it has several issues:

  1. There is a high frequency noise that seems to be proportional to how many LEDs are lit on the strip.
  2. There is a low frequency noise (~25Hz) whenever the Arduino board is connected to the system.

Next step is to identify the sources of these noises and eliminate them. But so far I am satisfied with the progress.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this:
search previous next tag category expand menu location phone mail time cart zoom edit close