Arduino Spectrum Analyzer on a 10x10 RGB LED-Matrix

47,299

261

94

Introduction: Arduino Spectrum Analyzer on a 10x10 RGB LED-Matrix

In this Instructables I am going to show you how to create a spectrum analyzer powered by an Arduino nano. Please watch my video first to get a rough explaination on how to build it.

A spectrum analyzer basically analyzes the intensity of different frequencies in a song. To display those values we are going to use a 10x10 RGB LED-Matrix. Every time one of the columns reaches the top of the matrix the hue value of the colors increases and the matrix looks different.

Step 1: Building the Matrix

To make this awesome spectrum analyzer I first had to build the RGB LED-Matrix. To accomplish this task I have followed the Tutorial of GreatScott on YouTube. He did an awesome job in explaining how to build such a matrix. Just follow the video step by step or use his Instructables as an instruction and then come back and follow the next steps.

Important note: make sure your LEDs are connected as shown in the diagram above. Otherwise my sketch won't work flawless with your matrix.

Step 2: Additional Parts

To convert your Matrix into a spectrum analyzer you need the following additional components:

  • 2x 3.5mm headphone sockets
  • 2x 1.8kOhm resistors
  • 1x 4.7kOhm resistor
  • some flexible wire

First of all I had to include the two headphone sockets to the matrix. We use them to loop the audio signal through the matrix to analyze it. We basically connect our audio source (e.g. a smartphone) to one of them and a speaker to the other one. I just drilled two holes according to the diameter of my sockets and glued them in place with two component adhesive.

In the next step you will see why we need those resistors.

Step 3: Connecting the Components

First of all, I have connected 3.3V to the AREF pin of the Arduino through a 4.7kOhm resistor. This is to get a better resolution of the sampled values of the audio signal since they normally reach a maximum of only 1V Peak-to-peak. The reason why we get a better resolution is that the 1024 values of the ADC are now not longer mapped to 0-5V but to 0-2.88V (2.88V because of the 4.7kOhm resistor). To understand why we used a 4.7kOhm resistor and how I have calculated those 2.88V have a look at the analog reference article on the Arduino website.

But there is one problem if you want to analyze an audio signal with an Arduino. The signal is mirrored around 0V. Therefore we get both positive and negative voltage peeks. And because Arduinos can't handle negative voltages we have to get rid of them and create an offset.

As you can see in the schematic above I used a voltage divider with two 1.8kOhm resistors to solve this problem. Since they have both the same resistance the signal now alters around 1.44V (2.88V/2) and we got rid of those negative voltages. To make life easier you can solder the resistors directly to the pins of your Arduino nano.

Lastly I connected the two audio jacks. I simply connected both right and both left channels to each other. I then soldered both GND pins together and connected them to the GND wire of the matrix. Which of the two channels you then connect to the Arduinos A7 Pin / voltage divider doesn't really matter.

Step 4: Programming

To program the built in Arduino nano you first of all have to download both the FastLED and the FFT library. Make sure you have exactly these versions of the libraries listed below otherwise the sketch may not work. Also check if you use at least Arduino IDE 1.6.8 or higher. After you have included both libraries into your Arduino IDE you have to open the "SpectrumAnalyzer" sketch.

Now change the data pin of your LEDs, upload it to your Arduino, connect an audio source and speakers and it is done!

Hope I could help you with this Instructables. If you have any questions feel free to ask them in the comments section below.

Make it Glow Contest 2016

Participated in the
Make it Glow Contest 2016

First Time Authors Contest 2016

Participated in the
First Time Authors Contest 2016

Be the First to Share

    Recommendations

    • Battery Powered Contest

      Battery Powered Contest
    • Plywood Challenge

      Plywood Challenge
    • Plastic Contest

      Plastic Contest

    94 Discussions

    0
    blynksorin
    blynksorin

    4 months ago

    Hi, I tried to compile the ino file before to load it in a nano and I've got error - r28 cannot be used in asm here, same with r29.... Can you help me to solve it? I use Arduino 1.8.13 and libraries indicated above.

    1
    Grumpy Mike
    Grumpy Mike

    Question 2 years ago

    That input circuit is a mess and risks damaging your audio device and your Arduino. You have not understood what you have read on the Arduino page.
    R2 should be connected to ground not your audio input. Your audio input should be connected to A7 through a series capacitor. You should not connect anything to the Aref input and R3 should go straight to the 5V connector.

    0
    amilaneranjan
    amilaneranjan

    Answer 4 months ago

    @Grumpy Mike can you tell me whet are the R2 and R3 pin in nano??

    0
    Grumpy Mike
    Grumpy Mike

    Reply 4 months ago

    R2 and R3 are not pins in the Nano. They are resistors that are connected to pins. As it stands on the original diagram R3 is connected between the Aref and the A7 pin on the Nano, and R2 is connected between A7 and the audio input.

    0
    meng korng
    meng korng

    8 months ago

    i don't see code arduino ?

    0
    bosticnj
    bosticnj

    Question 8 months ago

    Hello,

    I have a Arduino Mega that came with a kit and I am having trouble getting the code to load. Do you have any suggestions?

    0
    Kirk Tindel
    Kirk Tindel

    Question 1 year ago on Introduction

    I built this and it seems to work great for regular music - but I'm using it with a guitar amplifier and noticing that even with there being no sound (including hum or anything, just complete silence) I still get almost full peaks showing.

    Is there a way to adjust the sensitivity through code, instead of having to solder in new resistor values (and guess around with that until I get the right ones)?

    Thanks for the code, though - works great!

    0
    TheBoj
    TheBoj

    1 year ago

    Great project FischiMc. Thank you for posting.
    As I am new to
    Arduino and am looking to build this so I might be asking a silly
    question here. Can someone post a diagram as to how the LED strip
    connects to the Arduino board?
    Does the power supply still connect
    directly the LED strip also go to Arduino 5V pin and ground as well as
    data from LED strip to D3? Then we simply add the components listed in
    your schematic? Also which lines need to be modified to in number of
    rows or columns? EG 15 rows x 20
    Ive already soldered the LED's as described in the video just wanting to clarify.

    Thank you

    0
    bcoffe73
    bcoffe73

    Question 1 year ago

    game

    0
    BrynM3
    BrynM3

    Question 2 years ago

    Would it be possbile to use the esp8266 for this

    0
    JazzHandsFrenzy
    JazzHandsFrenzy

    Answer 2 years ago

    I honestly have no clue since I have never played with one. I may think about getting one though since it has WiFi built in. For now, I only got the Arduino working and you can use a Bluetooth module to change colors.

    0
    JazzHandsFrenzy
    JazzHandsFrenzy

    Reply 1 year ago

    i have just got myself a esp8266 and am currently working on a code for it that will have a web based gui. I am going off of someone else's code but tying to adapt it to work for this guide. if you are still interested, let me know and ill try and help you with setup.

    0
    Cantdoit
    Cantdoit

    Reply 1 year ago

    Do you know if it's possible to run this on a Photon Particle? Or is it even worth having..

    0
    JazzHandsFrenzy
    JazzHandsFrenzy

    Reply 1 year ago

    is that similar to the esp8266? and please email me at jazzhandsfrenzy@gmail.com for better communication. i am always willing to help and adapt code to more devices.

    0
    Jhon MarvinL
    Jhon MarvinL

    Reply 1 year ago

    Hi! Can I ask what parameters I should change in your code in order to implement this on a 3x10 Matrix? I want to use this for 3 frequencies only. Thanks a lot!!

    1
    JazzHandsFrenzy
    JazzHandsFrenzy

    Reply 1 year ago

    I added comments, just search for matrix7 and read instructions throughout the code.

    0
    Jhon MarvinL
    Jhon MarvinL

    Reply 1 year ago

    Hi! I'm sorry to bother again. Your code works flawlessly. However, I messed up during soldering so I can only have a 3x9 Matrix. Can I ask if the comments you put can also be applied for height change, or should I change more parameters? Thanks a lot!!!

    0
    Jhon MarvinL
    Jhon MarvinL

    Reply 1 year ago

    I'm also not sure about what to do regarding line 85 because you said to change the max dot count to the width if I am keeping the 10 height. What should I do if I have to change the height as well?

    0
    JazzHandsFrenzy
    JazzHandsFrenzy

    Reply 1 year ago

    Email me at jazzhandsfrenzy@gmail.com and I will be able to hopefully guide you to getting the matrix all set up for you. I can't help you right now but should be able to help and maybe even test a code for you within 24 hours hopefully.