Maker.io main logo

Sound Reactive Paper Lanterns with LedFx

2024-05-14 | By Adafruit Industries

License: See Original Project LEDs / Discrete / Modules Wifi Wireless Adafruit Feather

Courtesy of Adafruit

Guide by Erin St Blaine

Overview

 

Create an array of paper lanterns and control them with sound.‎

This guide uses a Feather ESP32 V2 loaded with the free, open ‎source WLED software.‎

WLED runs on the Feather, using WiFi to allow you to control the ‎lights with your phone, PC, or any wifi-enabled device. This is a lot of ‎fun and will make for a beautiful piece of light art in your space ‎that's easy to control and program with your phone.‎

But this guide goes further! WLED interfaces seamlessly with LEDFx, ‎an open-source program that runs on your computer to capture and ‎analyze sound, either from your music player or from your ‎computer's microphone. It takes the sound and translates it into ‎light effects, so your lights can run sound-reactive animations over ‎WiFi without needing to add a physical microphone.‎

WLED has sound reactive effects. Why not just use WLED?‎

WLED does have sound reactive modes available, but the sound ‎needs to be run and processed through a small microphone ‎soldered to your ESP32. These microphones don't have the same ‎quality pickup as the one on your PC and may not be physically ‎located where the sound is optimal. The effects don't have as many ‎controls and tend to be a little "blinky".‎

LEDFx gives you great sound input and a lot of solid animations with ‎controls that allow you to really dial in your animations. It's just as ‎easy to use but I've gotten much nicer results with LEDFx.‎

Parts

Additional Materials

  • Paper lanterns in various sizes
  • A computer and speakers to run the software

Wiring Diagram

diagram_1

Feather Setup

Power comes in through the screw terminal and passes through the ‎on/off switch, then splits to go to the Feather (via the JST port) and ‎also to the LEDs. This is a safer way to power a large number of lights, ‎since it doesn't pull all the power the lights require through the ‎delicate electronics in the Feather.‎

NeoPixel Strand Setup

Each NeoPixel ring is connected to 4 wires: power, ground, data IN, ‎and data OUT.‎

The power and ground wires all connect together to a "power rail" ‎which runs the length of the strand. We'll wire all the 5v pins on the ‎rings to the red wire, and all the g pins to the black wire.‎

The data wires are doing something a little trickier. The first ‎data IN on the ring is connected to GPIO pin 12 on the Feather. The ‎data OUT pin on this ring then connects to the data IN pin on the ‎next ring in the series, and so on down the line. ‎

I've used a 3-pin JST connector (not shown in the diagram) to ‎connect the strand of lights to the microcontroller and switch. This is ‎optional but allows me to easily remove the Feather from the strand ‎in case I want to update it or borrow it for a different project.‎

WLED Software

Install WLED

These next steps require a WebSerial-compatible browser. As of ‎this writing, that ‎means Google Chrome, Microsoft Edge, or Opera “desktop” ‎browsers. Other browsers (Safari, Firefox, Explorer, ‎and anything mobile) won’t work.‎

Visit https://install.wled.me/‎

Plug your microcontroller into your computer with a known good ‎USB cable. Click "Install" and select the port for your board.‎

Depending on the USB-to-serial bridge chip on the board, you might ‎see one or two serial ports. On Mac, for instance, there might be both ‎“/dev/cu.usbmodem[number]” and “/dev/cu.wchusbserial[number]”. ‎Use the “wchusbserial” one.‎

webinstaller_3

After successful installation, enter your WiFi network name and ‎password when prompted. This must be a 2.4 GHz WiFi network; ‎ESP32 does not support 5 GHz networks. If it can’t connect, then as a ‎fallback WLED will create its own 2.4 GHz WiFi access point.‎

Setup & Preferences

WiFi Setup

It's a good idea to head to WiFi Setup screen and create a good URL ‎so you can control your project from any web-enabled device. I ‎called mine http://spheres.local -- this is what I type into any web ‎browser on my WiFi network in order to connect to my project.‎

screen_2

screen_3

LED Preferences

You need to change just a couple of settings in the app to get the ‎lights running correctly. Click the LED Preferences tab and scroll ‎down to Hardware Setup. Enter the total number of LEDs in your ‎strip under "Length". My strip has 15 rings with 12 pixels each, so, 180 ‎pixels total.‎

The NeoPixel data pin is connected to pin 12 on the Feather, so make ‎GPIO match that pin number.

prefer_4

Use It

use_5

Now you can use any computer or handheld device to control your ‎LEDs. ‎

Make sure your device is on the same WiFi network as your board. ‎Navigate to your custom URL (http://spheres.local/ for me) in a web ‎browser. You'll see a color picker above a whole bunch of color ‎palette choices.‎

Choose a color, choose an effect, and watch your lights animate and ‎glow!‎

Usage

Save your favorite combinations as presets, create playlists, control ‎the speed and intensity of the animations, and lots more. This web ‎app is incredibly intuitive and easy to use.‎

Head over to the WLED wiki at https://kno.wled.ge/ to delve into all the ‎particulars.‎

Electronics Assembly

Plug the male end of the power switch into your Feather's JST port.‎

Cut the female JST connector off the other side of the switch. Strip ‎some shielding from the wires and screw them securely into your ‎screw terminal, red to + and black to -.‎

I like to strip around ½” and fold the bare wires over onto themselves ‎before I stuff them into the screw holes, just to give the hardware a ‎little more to grab.‎

cut_5

Cut the wires going to the male JST connector (currently plugged ‎into the Feather.) ‎

Solder the middle wire from the JST connector (green, in my case) ‎into pin 12 on your Feather. This is our data wire.‎

Twist the wires you just cut back together and splice them to your 3-‎pin JST connector's red and black wires. These will feed power to the ‎Feather and to the lights.‎

twist_6

twist_7

Solder the red wires to the leftmost wire (red) and the black wires to ‎the rightmost wire (white on this connector).‎

solder_8

A Word about Connectors

These little locking JST connectors are very handy and they're ‎everywhere in DIY electronics projects. They come soldered to the ‎ends of LED strips and many of us eventually end up with a drawer ‎full of these, salvaged from various projects.‎

However, there seems to be no industry standard for color-coding. ‎Sometimes you'll find a connector where the red wire is on the left, ‎and sometimes it's on the right. This can be really problematic. ‎When you're knee-deep in a project and trying to keep diagrams ‎straight in your head, it's VERY easy to just roll with whatever color ‎code schema is in front of you. But just because the wire is red on ‎your connector does not mean it's going to neatly line up with the ‎power wires in your project.‎

Note how this connector I'm using has the red wire on the left, and ‎the connector that comes with this LED strip has the red wire on the ‎right. Hooking this up will cause a short circuit, because power and ‎ground will be reversed. This is a great way to damage the ‎electronics, so always double check your wiring and don't depend on ‎color coding!‎

red_9

Strand Wiring

I have 15 lights in my strand, and 6 different sizes of lanterns. I ‎wanted them to be in a pleasing layout -- not too close together, not ‎too far apart, with varying heights and sizes.‎

Cut 15 pieces of ribbon cable in varying lengths. Mine are 6" at the ‎shortest and 34" at the longest, in 2" intervals. ‎

I used a one-inch gridded self-healing cutting mat to lay the wires ‎out and this made the measuring and cutting really easy.‎

cut_10

There are a lot of rings, and each ring has 4 connections. That's 60 ‎solder points we'll have to hit. I find that big, tedious tasks like this go ‎much faster and save a lot of precious brain cycles if you do ALL the ‎stripping then ALL the soldering, instead of processing one at a ‎time.

Separate the wires in the ribbon cable at one end. Strip about 1/8" of ‎shielding from all 60 wires.

rings_11a

rings_11

Solder each ring to a piece of ribbon cable, paying close attention to ‎the order of the wires:‎

  • Striped wire: 5V
  • ‎2nd wire: data OUT
  • ‎3rd wire: data IN
  • ‎4th wire: G

‎Be 100% consistent here or your whole strand will not work. I found it ‎easiest to solder the striped wire first, then work my way clockwise ‎around the ring: G next (easy to find since it's on the other edge), ‎then IN and OUT fall right into place with no crossed wires.‎

wires_12

wires_13

Prepare the Power Rail

Cut a long wire for the top of the strand. I'll refer to this as the "power ‎rail".‎

Find the striped wire. This will be our power wire (+5v) and will attach ‎to all the striped wires coming from the rings.‎

We only need 3 wires in our power rail, so separate the 4th wire and ‎pull it off the cable. Save it for another project.‎

The 3rd wire, which is now on the edge, will be our G wire, and the ‎middle wire becomes our data wire. Check the wiring diagram page ‎to see how this works.‎

prepare_14

Plug your female JST connector into the male connector on the ‎Feather, so you can be sure which wire should go where. Connect ‎the female JST connector to your power rail as shown red / USB to ‎the striped wire, green/data to the middle wire, and G to the 3rd ‎wire. ‎

This is now the IN end. Keep it on the left as you work.‎

in_15

in_16

Stretch out your 3-wire power rail on the floor and arrange the ‎lanterns below it. Lay out your wires and trim any that are too long.

stretch_17

My lanterns do not have mathematically even spacing, since the ‎sizes are so different - a more random layout looks better. In order to ‎mark the spots where the lanterns attach, I pulled the 3 wires on the ‎power rail apart by about an inch at each spot where a lantern will ‎go. Now I can pick up my power rail to work on it and still be sure of ‎my spacing.‎

rail_18

Starting with your first lantern, Cut the middle wire and strip about ‎‎1/4" of shielding off each side. The left wire is where the data comes ‎IN and the right-side wire is where the data will travel OUT to the ‎next lantern.‎

Keep the power and ground wires intact but cut through just the ‎shielding and pull it back a bit to expose a little of each of the wires. ‎This makes our splicing job a little easier and keeps more power ‎running through the project, since the wires remain unbroken ‎through the whole length of the strand.‎

strand_19

Grab your first lantern ring. Separate the wires and slide a piece of ‎heat shrink onto each one. I also added a large piece of heat shrink ‎to cover all 4 connections and make the joint look tidy afterwards.‎

heatshrink_20

Now, make your connections. Twist the striped wire from the ring ‎around the bare patch of striped wire on your power rail. Then do the ‎same with the 3rd (G) wire -- it will connect to the 4th wire on the ‎ring.‎

Connect the next wire over (going to IN on the ring) to the cut wire ‎on the left, and the remaining wire (coming from OUT on the ring) to ‎the cut wire on the right. Solder all 4 connections. ‎

connect_21

Time to test! Plug in your Feather and the power supply, click the ‎switch if needed, and make sure the lights come on. If they did, ‎congratulations! Solder on, my friend.‎

Keeping the wires straight is tricky business -- it's really easy to ‎solder things up wrong. I made sure to keep the IN end of the power ‎rail on my left the whole time, so I could always be assured of which ‎side was IN and which was OUT. ‎

If the lights don't come on, or are doing something unexpected, here ‎are a few troubleshooting tips. Get this first one fixed before moving ‎on to the rest.‎

Troubleshooting

If your lights didn't come on, here are a few things to try:‎

  1. ‎Flip your on/off switch. Was it just turned off?‎‎
  2. Head back to WLED and check your pinout configuration ‎under LED Preferences. Be sure your data wire is connected to ‎pin 12, and that you've told WLED it's on 12.
  3. Check your wiring! This is a bit of a complicated mess until you ‎get the flow right and it's really easy to crosswire something. ‎Trace your wires and be sure power is going to the striped wire ‎everywhere, and that IN on the ring is connected to the wire ‎that leads to the Feather's pin 12.‎‎
  4. Try re-uploading the WLED software‎.
  5. Make sure you're on the correct WiFi network - if you're on a ‎different network you won't see the WLED connection.
  6. Check further down the line and be sure nothing is shorting out. ‎I stripped some wires further down in anticipation, and they ‎touched together and shorted out my project, making testing ‎VERY difficult.‎

Open the paper lanterns. Each one will have a wire frame inside that ‎holds the lantern open. ‎

I used a zip tie to secure the ring to the frame right at the top of the ‎lantern.‎

These little lanterns rip easily, and the strand can get pretty tangled ‎up. I found it easiest to hang the strand with the metal frames ‎attached, and then add the lanterns once everything was in place ‎and ready to go.‎

lantern_22

window_23

LEDFx Software

Head to LedFx.app and download the version of the software that will ‎work with your computer. There are installers for Mac, Windows, and ‎Linux.‎

Run the installer and open the app. ‎

Click the orange + button to add a device. Choose WLED from the ‎device type popup.‎

click_24

click_25

Pop back over to WLED (http://spheres.local) and go to Config > Wifi ‎Setup. Scroll down until you find the IP address of your device. ‎Copy it into your clipboard.‎

Back in LedFx, give your device a name and paste the IP address ‎into the appropriate field. Click "Add."‎

add_26

add_27

Click "settings" at the bottom right and open the Audio settings. This ‎is where you can choose your audio input. It defaults to your ‎computer's microphone. ‎

Check the LedFx docs under "Directing Audio" to learn to add different ‎sound input devices. ‎

devices_28

The user interface is fairly simple and easy to figure out. Select an ‎animation mode and make some noise to see the sound play out on ‎your spheres.‎

For more help or ideas, check out the LedFx Discord server.

interface_29

complete_30

制造商零件编号 5400
ESP32 FEATHER V2 STEMMA QT
Adafruit Industries LLC
¥162.39
Details
制造商零件编号 1643
ADDRESS LED RING SERIAL RGB
Adafruit Industries LLC
¥63.19
Details
制造商零件编号 3064
JST-PH2 EXT CBL 2PIN SWITCH 20"
Adafruit Industries LLC
¥24.01
Details
制造商零件编号 368
ADAPT TERM BL 2POS TO 2.1MM JCK
Adafruit Industries LLC
¥16.28
Details
Add all DigiKey Parts to Cart
TechForum

Have questions or comments? Continue the conversation on TechForum, DigiKey's online community and technical resource.

Visit TechForum