Introduction: 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)
- 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
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.
- Download the DiscoJar source code from GitHub and compile and upload the program to the Teensy using a USB cable
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+CWJAP_DEF="NetworkName"，"your wifi password"
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:
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.
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!
We have a be nice policy.
Please be positive and constructive.