Audio Reactive LED Strip with Raspberry Pi + Pi giveaway

Published on: December 8, 2018

Welcome to the third Raspberry Pi tutorial! Thank you all so much for your support as I get this series rolling. Before I get to the giveaway, let's talk about the tutorial, nicknamed Dancy-pi (I know, not the best name) or Danceberry Pi (better?). 

The project will cover how to create an Audio Reactive LED Strip with a Raspberry Pi 3. Although you can do this project with the Pi Zero, I've noticed that the Zero has trouble keeping up with the data if there's too much happening. So I would recommend a Pi 3. Here's the product list:

  1. Raspberry Pi 3 (Pi Zero/W will also work but you may see less efficient performance)
  2. WS2812b LED - can be a strip or in any basic series. You should know the number of LEDs in the series. 
  3. Microphone - I use a basic USB mic in the video
  4. Jumper cables - to connect the Pi to the lights
  5. Power - this can be supplied to the Pi and the Pi supplies power to the lights, or you can use two different power sources for the two components

I also use aluminum LED extrusions in the video but that is optional. 

For more information the commands needed to install dependencies, please see the following Github page:

The above repository is a fork of Scott Lawson's work on the controller. I made modifications based on what worked for me. I also decided to use a USB microphone because I noticed that tutorials around this project all focused on the use of the ESP8266 module. Although the ESP8266 module would be more of a lossless solution, a USB mic may be easier to get your hands on. So my project is optimized for that. You can find all of my customizations in the github repo above. 

Let's start with getting our software ready by making sure our Pi is up to date with

    sudo apt update && sudo apt upgrade

The dependencies that this

    sudo apt install python-numpy python-scipy python-pyaudio python-pyqtgraph

I explain this in the video and on Github, and I want to highlight the changes I made to

    DEVICE = 'pi'
    LED_PIN = 18
    USE_GUI = False
    DISPLAY_FPS = False
    N_PIXELS = 142
    MIC_RATE = 48000
    FPS = 50

Getting the MIC_RATE right is important. If you run into random unexplainable errors with your mic, check the rate! Although the N_PIXELS variable is not as important, it's still good to get that number correct, because it'll determine where the center is and start the 'dancing' there. 

By default, the project uses GPIO Pin 18 as the data pin with 5v and GND pins being any of the ones provided by the Pi. Find a quick the wiring below (Note: I'm using a Pi0 as the hardware even though I'm using a Pi 3 for the project - just reusing some graphics from another project!):

Fritz Diagram Raspberry Pi connecting to WS2812b LED Strip
Click image to see full resolution

Running the script is pretty simple:

    sudo python spectrum

Substitute the visualization_type placeholder above with any of the following:

  • spectrum
  • scroll
  • energy

Each of the visualization types will give you a different type of dancing lights. I demo all three in the video below. Have questions about my customizations or just Raspberry Pi in general? Ask below!

Now you're probably getting impatient and want to learn about the giveaway. 


In today's tutorial, I will give away at least 3 Raspberry Pi Zero Ws! In the first giveaway, I said that I was going to give away 2, then I changed it to 3 during the drawing because the number of people who were interested was amazing and I was blown away by the interest and support. But I actually gave away 4. The fourth winner was an honorary winner, someone who engaged in conversation and showed that he really wants to learn. I saw a lot of potential so I sent him one. I am not going to make any promises but if I do see someone who really deserves one, shows interest and potential, and if I can get my hands on an extra Pi, I will pick another. Again, no promises! You never know though. 

The entry method is the same as last time. All I want is a comment from you. I'll already assume that you love Pi so I need something more this time! What do you want to do with the Pi? What projects have you already done? Why do you want the Pi? I'm pretty easy going so I'll probably accept anything.

Final entries are due by December 18, 2018 11:59:59 PM EST!

Here are a list of official rules:

  1. Only open to US residents (sorry, I will try to open it up internationally in the future)
  2. Comment anywhere in this video or on the video posted on - unlike the first giveaway, I want to hear a little more about what you want to do with the Pi. Do you have a project in mind? Do you just want to learn? 
  3. Optional: Mention what state you are from.
  4. I will stop taking entries on December 18, 2018 11:59:59 PM EST and winners will be announced in the December 22, 2018 tutorial
  5. That's all! 

Past winners are welcome to try again! Comments on YouTube and EasyProgramming will earn you one entry each. Patrons on Patreon will get 5 entries per tier! Meaning you can get up to 15 entries on Patreon alone. Look to becoming a patron:

Bonus entry can be made on the EP subreddit, so be on the lookout for that thread:

I apologize again for opening up to US residents only. Since I'm covering the costs myself, I need to be able to minimize costs so that give away more of these. International shipping is just so expensive! I do hope to open it to international folks at some point. 

Enjoy the tutorial and good luck in the drawing! The winners will be announced in two weeks. I plan on doing more giveaways in the future so subscribe if you want to stay up to date. 

Remember to checkout the Resources section below for associated downloadable content, JSFiddle links, and other resources. Watch the video and follow along!