DiscoJar: Sound Reactive Lamp With 288 RGB LEDs

13K12817

Intro: DiscoJar: Sound Reactive Lamp With 288 RGB LEDs

DiscoJar is a sound reactive DIY LED lamp, using an Ikea jar and 288 APA102 LEDs.
It does real-time spectrum analysis of the audio input and shows a colorful view of it.

This instructable will guide you how to build your own DiscoJar! It provides instructions and the full source code for the micro controller.

A Teensy 3.2 micro controller is used to control the LEDs and to analyze and display the spectrum of incoming music using various visual effects. The lamp features a WiFi remote control and it can also be used as a mood lamp. It can e.g. show plasma effects or you can program your own custom patterns.

Building the project costs around 100 Euros, the LEDs are the most expensive part.

The project is easy to build, all you need are some soldering skills to solder the APA strips together.

Parts that you need:
  • Ikea Droppar Jar with frosted glas (www.ikea.com/de/de/catalog/products/20112544/) (which has a diameter of 9 cm)
  • PVC tube or cardboard tube (approx. 27cm long, with 4cm diameter)
  • Two strips of APA102c LEDs with 144 LEDs per meter (ebay)
  • LED power supply 5V, for example (LED Power Supply 13W 5V 2,6A)
    (at least 2A, dependend on the maximum brighness that you want to use)
  • Audio jack socket (my favourite: Adafruit)
  • Audio cable male to male
  • Audio Y connector (to connect sound signal to amplifier and lamp at the same time)
  • 2x 47kΩ resistor, 1x 10kΩ resistor, 1x 2.2kΩ resistor, 1x 1kΩ resistor
  • 2x 10µF capacitor
  • Teensy 3.2 microcontroller (Teensy), I prefer the one with soldered header pins
  • prototyping PCB or breadboard
  • soldering iron + wires
  • hot glue or other glue
  • a case for the electronics (I used an old round iPod Dock, you can use any kind of box but round will look best)
  • ESP8266 (if you want to control the lamp via WiFi) (ebay)

STEP 1: Preparing the LED Strips

The APA102c strips are amazing technology! You can control each LED individually via SPI by using only two wires (clock and data). The easiest way to control them is using the FastLED library, which is part of the Teensy Installation (see software later on).

For our project, we need two APA102c strips with 144 LEDs (1 meter each).

We want to have a single 2 meter strip, so our first task is to unsolder the connector cables from the two strips, except for the input connector of one of the strips. After doing this, we need to solder the end of the first strip to the start of the second strip. I kept the power supply cables on the last strip, so that the strips are powered from the start and the end, but this might not be necessary.

As a result we have a 2 meter strip with 288 LEDs and a single input connector with VCC, CLOCK, DATA and GND.

Power supply consideration

Since the strips draw quite a lot of current, we need an extra power supply. I used a 2.6 amp 5V power supply for LEDs (see part list). In theory and at maximum brightness, each LED can consume up to 0.2 watts, so 288 x 0.2 watt = 57 watt. But since we don't use the LEDs at full brightness and never turn them all to white, power consumption is not that dramatic. I measured 1.25 A current in normal low brightness mode and up to 2.2 A on high brightness showing a rainbow. You can also use an old PC ATX power supply, but I recommend a LED power supply as linked in the parts list because it is much more compact.

STEP 2: Preparing the Jar

The Ikea jar I used is called Droppar and has a diameter of 9 cm with frosted glas (www.ikea.com/de/de/catalog/products/20112544/), so it is ideal to use it as a lamp. We will turn the jar upside down and put a tube with LEDs into it.

First of all, we need to remove the glas inside the lid, so that we can put our wires through. Use a small hammer to break it (and please don't hurt yourself) and remove it completely.

Afterwards, I recommend to paint the bottom of the jar (which is not frosted) with a spray can, so that the LEDs are only visible through the frosted glas.

The next step is to cut a PVC or cardboard tube (4 cm diameter) to a length that fits into the jar, approx. 27cm (or a bit longer depending on your case).

Now we need to glue the 2m LED strip to the outside of the tube, starting from the bottom in a equidistant spiral. Finally you should have a tube of LEDs that fits nicely inside the center of the jar. To avoid that it can move in the final installation, glue a cork to the center of the bottom of the jar, so that the tube can be plugged onto the cork (see images).

STEP 3: Wiring the Teensy

Now that we have the jar with the LED strips, we need to build the electronics to control them.

You can either use a breadboard or (like me) use a prototyping PCB to solder the circuit.

We have the following parts in the circuit:

  • Teensy 3.2
  • LED power supply
  • LED strip connector
  • Audio input circuit
  • ESP8266 (optional)

The connections are as follows:

  • The audio signal needs to be converted from the AC RC level to a positive range that can be read with the ADC of the Teensy. For this we build the conversion circuit as provided on the Teensy Audio Library repository.
  • The Teensy needs to be connected to the APA102 strips
    • D13 (CLK) to CLOCK of the APA strip (named C or CLK and colored in yellow)
    • D11 (MOSI) to DATA IN of tha APA strip (named D or DI and colored in green)
  • If you want to power the Teensy using the 5V LED power supply, then you should disable the USB power of the Teensy (this can be done by cutting the connection between USB/VIN pads).Note: Once you cut the USB/Vin connection, the Teensy will always need power on the Vin.
  • If you use the extra ESP8266, wiring is as follows:
    • 3.3V Teensy to 3.3V ESP (the regulator of the Teensy 3.2 can handle this!)
    • GND Teensy to GND ESP
    • 3.3V Teensy + 1K pull up resistor to CHIP_ENABLE (CH_EN)
    • RX1 Teensy to TX ESP
    • TX1 Teensy to RX ESP
  • The APA102 LEDs expect 5V input signals, but the 3.3V is in the range to be detected has HIGH, so no logic level conversion is required.

STEP 4: The Software/Firmware

If you don't know the Teensy yet, don't be afraid of it! It is as easy to use as an Arduino and has much more horse power and a very nice Audio library.

The source contains:

  • FFT spectrum analyzer code
  • different visualization modes that can be switched via WiFi or in the code (or you could add a button to control the modes)
  • a simple web server that serves the home page and accepts POST requests to change settings

By default, the WiFi remote is disabled, so that you can test your project without WiFi setup. Once you are ready to add WiFi (as described in the next step), you can simply enable WiFi in the first lines of DiscoJar.ino by uncommenting USE_WIFI, and recompiling the sketch.

When the DiscoJar boots up, it shows a rainbow, so that you know that the LEDs are correctly wired. Afterwards it starts the web server and runs the default spectrum analyzer.

If the WiFi remote is enabled, you can change various parameters via the web page, see next step.

STEP 5: Setup WiFi Remote Control

Since both the Teensy and the ESP8266 are 3.3V devices and the Teensy 3.2 provides enough current on its 3.3V output, it is fairly easy to add a ESP8266 to a Teensy project, wired as shown in the previous step.

To initially setup the ESP8266, it is the easiest to upload a simple serial forwarding sketch to the Teensy (as provided here), which just forwards all communication from the Teensy USB serial to the ESP8266 and vice versa (a more detailed guide is here).

Set the serial monitor to 115200 baud and run the simple sketch to setup the ESP8266.

I recommend that you configure it to auto-connect to your WIFI, so that the DiscoJar just detects an auto-connected ESP and does not need the credentials.

This is done as follows:

AT+CWMODE_DEF=3
AT+CWJAP_DEF="NetworkName","your wifi password"
AT+CWAUTOCONN=1

Once you have done this, you can just enable the WIFI support in the DiscoJar sketch (#define USE_WIFI in DiscoJar.ino).

The DiscoJar will serve a web page at the IP/name of the ESP, so you can just point you Webbrowser to the ESP and can control the lamp. You can find out the name and IP by looking onto your router or by asking the ESP with:

AT+CIFSR

To enable debug output in the DiscoJar.ino, go to WiFiControl.h and uncomment the PRINT_DEBUG define. This will print all communcation with the ESP to the USB serial of the Teensy.

STEP 6: The Finishing Touches

To make it a nice lamp, we need a nice case for the electronics. I had an old round iPod dock lying around, so I cleaned that out and put the power supply and the PCB into that case, which gave me a nice overall look.

I recommend that you look for a round case, but of course you can use any case you can fit the electronics in and the jar on top. Wood might also be a nice option.

Future Ideas

I plan to extend the software by additional spectrum analyzer effects and to improve the WiFi remote. Feel free to try writing your own patterns/effects and post them in the comments!

16 Comments

Hi DeltaFlo,
I finally took the time to produce a similar lamp. This instructable is very detailed, with nice pictures and easy steps to work the project! Many thanks for this!

But I still have two questions about step 5. I didn't install the wifi-module, so I'm kinda bound to load the modes via the cable. Thats not a problem for now, but I would like to know what I change when I change the gain and the decay? And whether or not there are maximal values I shouldn't exceed by changing the brightness, gain and decay?

Thanks in advance!
oh yes, and sorry to ask so many questions, but another problem i have is that i can't play music through speakers at the same time as i am feeding in the music! any speakers i have with an amp (basically all speakers) seem to short out the connection... so currently it only works with headphones (and then of course only mono)... how did you get it to work with normal 3.5 jack speakers?
hi DeltaFlo, thank you for sharing this incredible project, really hope i can make it work! i'm a newbie trying to build it now, and have run into two questions trying to troubleshoot why it's not working yet...hope you can help me out, thanks so much!
1) Is the disabling of the USB power of the Teensy optional? Because i see in your photos that the USB is always still attached. If you leave it attached, then does the USB always still need to be plugged in at the same time as plugging in the 5V LED power?
2) The audio input jack has 5 pins, and I can't tell from the diagram exactly which pin the blue wire is connected to (is it pin #4 or #5 as based in the schematic here? http://anacapa.kycon.com/Pub_Eng_Draw/STX-3120-5B.pdf ). Assuming also that the ground wire is connected to pin #1, is that correct?)
Yes, one pin is the ground (1) and then you can take pin 5 or 2 (left or right channel). But I think even 3 or 4 would work, they are only used to detect if something is plugged in.

Regarding the Teensy power: If you power it from USB, then you should not power it from the LED power source, because this will put the LED power into your computer‘s USB. So when starting, I suggest using the USB power and not connect the LED 5V to the power input of the Teensy. Later, when everything works and you want the lamp to work without the USB connected to a power source, then you have to power the Teensy via power in. But since you probably still want to update the firmware from time to time and you don‘t want to burn your computer, that is the point in time when you should cut the USB power on the Teensy. At that point, it will work without USB power, but the LED power needs to be one to reprogram the firmware via USB because the USB no longer powers the teensy. (You can google for teensy /external power for more details)

sorry, long answer...hope it helps!
thanks so much for your quick response! okay, so basically i've got it working now, but it only works well with one meter of the LED strip (i haven't soldered the LEDs together yet, but have them connected with wire), and the second LED strip acts kind of wanky not fully lit and not really in time with the music. is this a power problem? I am powering the whole set up right now just via USB (2.1A). it took me so long to get it working, i'm a bit afraid to switch to DC power at risk of screwing the whole thing up! and also afraid to connect the LEDs together at risk of screwing that up, too, do you think i should just stick to 1 meter LED?
Hello, I saw your cool disco jar and decided to do it as a school project. I was wondering about that Y connector. You said that it's supposed to get plugged into the lamp and an amplifier, but with "lamp", do you mean the Audio jack socket? So that I plug it into a speaker and the socket from a computer?
Yes, because the disco jar only has an AudioIn socket, so you need a Y connector to connect the audio source to the disco jar and to loudspeakers. You can skip this if you have an amplifier that has audio out while still playing sound on the speakers, but on a typical PC the sound gets muted when plugging in an audio connector.
Okay thank you! One more question, could you please reply to this comment with some more pictures of how the wiring was soldered ? Both from above and underneath, if you still have it that is. Would be very appreciated

What libraries are needed for this? When I try to compile the code in the Arduino IDE from your github, I get errors saying "no such file or directory" for things like "fatal error: SerialFlash.h: No such file or directory".

Hm, did you install the Teensy Addon for the Arduino IDE?

And you need to select the Teensy as the target for building the code, since it uses Tennsy Libraries that re not available for Arduinos.

I was able to fix (I think) those errors stated above, but now I am confused on what State _myState does on line 37. What specific libraries do I need for this to work?

Amazing, any way to add a microphone rather than audio line in?

Yes, just search for teensy and microphone.

There is a discussion about this here:

https://forum.pjrc.com/threads/32178-Connecting-a-microphone
Superb. Definitely going to make this soon. Thank you for sharing.
Wow!!!! That's so awesome!!! Really GREAT!!