Bass Responsive RGB Leds Using Arduino

10K4910


Intro: Bass Responsive RGB Leds Using Arduino

This tutoiral will show you how to use Arduino and to control a set of leds using music played from your computer. This tutorial requires:

-Arduino (I used a leonardo)

-small breadboard w/ jumper wires (kit is the best deal)

-rgb led strip (I used these)

- 12v 6A power supply for the lights (something like this will be fine)

-3 N-Channel mosfets (here)

-A computer with processing 2.2.1 installed with the proper libraries

-and Arduino IDE

STEP 1: The Circuit

For this project to work, we will be using the PWM(Pulse Width Modulation) pins on the Arduino. These allow the signal being sent from these pins to change rapidly, which are detected by the mosfets, either completing or opening the circuit to the lights. Here, each strand is connected to it's own mosfet and PWM pin on the Arduino to allow for each strand to be controlled in dependently. Although the pictures are somewhat sloppy, you can use them as a guide of how you can fit the circuit on the breadboard.

Be sure the proper lead from the arduino are connected to the proper pins on the mosfet. The orientation should be the same as in the diagrams, so use the pictures are guides. Also ensure the 1K and 10K resistors are in the correct locations, as this will make the lights too dim.

STEP 2: Installing Processing With the Necessary Libraries

When I wrote the program, I was using processing 2.2.1. You could try to use the newest version, but there are very good odds the libraries will have changed and the functions used in this code will no longer be applicable. If you know what you're doing, you can try to get them working. But you will need to install these libraries (check my file paths above ignoring, all besides the 3 below):

-arduino

-controlP5

-Pframe

Download the processing .pde file and open it. Once the program is run, assuming the libraries are installed correctly, it will load the gui and start listening from your default audio device (probably a mic).

You will also need the Arduino IDE installed in order to load firmdata, code loaded onto the Arduino so it can talk to processing. I used 1.0.1, but you should be fine using a newer version.

The last setup step on the computer is to enable stereo mix. This is basically what your sound card is producing, so it will be a nice clean audio signal for processing to read.

Please try the following steps to enable the stereo mix and check if that help.
a) Right click on the audio icon in your system tray and select “Recording Devices” to open the Recording device settings in the “Sound” window.

b) In the pane, right-click on a blank area, and make sure both “View Disabled Devices” and “View Disconnected Devices” options are checked. You should be able to see the “Stereo Mix” option appearing. c) Right-click on “Stereo Mix” and click “Enable” to be able to use it. This should enable the “Stereo Mix” on Windows 8.

If this doesn't work, then you will need to install audio drivers that have stereo mix enabled. I used these, but it may vary depending on your OS.

STEP 3: Getting Everything Going

-Plug you arduino into your computer

-Load AnalogFirmata to the Arduino (ensure you select the correct COM port and device from the settings)

-Ensure the wiring between the arduino and breadboard is correct, stereo mix is enabled and the default audio device, and all connection are secure.

-When you play music you should see the light respond to bass signals and the EQ visualized in the gui. You can mess around with values on the gui to your liking.

That's it. I made a 3d printed enclosure for my setup so it's nice and safe under my desk.

10 Comments

A little late to the party, but here I go...

First of all, great project! Looks amazing in the video and you obviously spent a lot of time on the code and the setup - nice work!

I got intrigued by your post and decided to make it myself and bought everything I needed by impulse before checking that the code would even work with my arduino...

I followed your instructions to the point, installed libraries correctly and everything. What I'm getting now is a strange error at the line:

arduino = new Arduino(this, Arduino.list()[0], 57600);

With the error message:

"IllegalAccesError: tried to access class processing.core.PApplet$RegisteredMethods from class cc.arduino.Arduino$SerialProxy"

I'm not big in understanding error messages like that, but my intuition tells me that processing can't communicate with the arduino for whatever reason.

I looked online and I'm not the only one getting this. Apparently this is a bug in Processing 2.2.1 that happens whenever you try to make an Arduino and Processing communicate through the Firmata protocols. I've tried rolling Processing back to 1.5, but that just made it worse. I've tried the newer versions, still nothing. I've tried running in compatability mode, admin mode, everything I could find that the internet suggested.

As a last resort I'm writing to you, since I don't want all these electronics and money to go to waste. Can you possibly explain what is happening here and how I can fix it?

Alternatively, I read a couple of places that this has something to do with the arduino library not being updated for 2.2.1, and updating it (manually, which I have no idea how to do) would possibly fix it. I know it's a lot to ask, but could you upload the exact libraries that you used so I can download them? The only thing I can think that lets you run the code on 2.2.1 would be that you have the right libraries with the right contents... I could definitely be wrong though.

Sorry about all the text. Best wishes,

//Minibrams

Wish i could help, but i honestly have no idea what could be causing that. Only thing i can think of is using the correcr drivers and selecting the correct com port where the arduino is connected.
Hey. So I have a couple questions. Say I wanted to install this in a car for a subwoofer. Would it be safe to run it off of a 12v switched power source in the car? Also, is it possible to use this without it being connected to a computer? If you have any insight, I would greatly appreciate it!
Honestly don't know about the power supply question. The lights are 12vdc, so I assume it would work for the lights. However, the arduino uses 5vdc, so you would need to find a way to power that.

When I started the project, I had the intention to keep everything around my desk. So the code that controls the lights is written in processing for the sake of power and ease of coding. You can upload code to the arduino that's written in the arduino langauge, but it won't be nearly as powerful, but it can run without being tethered to the computer. I never figured out how to do fully responsive leds without processing.

This project looks amazing but I'm having some issues with Processing, specifically the program cannot find the libraries I installed. Where should I put the "sketchbook" and "libraries" folder that it asks for? I tried to follow the file path but it didn't bear any results. I'm on Windows 8.1.

I have my sketchbook pointing to where I installed processing (G:\Coding\processing-2.2.1), and therefore the libaries folder is where the sketchbook points (G:\Coding\processing-2.2.1\libraries). Let me know if that fixes it
Smart idea! I really like this project. Thanks for shearig :)
Nice instructable, but isn't it a bit "overkill" to use a microprocessor for this? You can achieve the exact same thing with an op-amp with an offset on the input. That makes it much cheaper to make. And it requires no programming.
That's probably true. But with this, you can also upload code to set the ambient lighting color, intensity, or a pattern like breathe or fade. I also was looking for a project to use my arduino for, but you're right, there are simpler ways to accomplish this.

Nice work! Thanks for sharing this.