LED System With Spectrum Analyzer

by collinmck in Circuits > Arduino

357 Views, 3 Favorites, 0 Comments

LED System With Spectrum Analyzer

IMG_9570.PNG
ET 370 Picture 2.jpg
ET 370 Picture 3.jpg

Collin McKinney and Jacob Gilbert

Acknowledgements:

Cal Maritime/ ET 370

Professor Chang-Siu

Professor Clyatt

Breauna Dickson

Erin Cole

Chris Mulhauser

The Idea:

The goal was to build a device that reacts to audio through LEDs. Beyond this mode we decided to add some other states that are common amongst led strips such as fade. The main mode the spectrum analyzer takes in music and surrounding audio and splits it into frequency bins which are assigned to bins on the LED strip. One other mode allows the used to manually adjust the color of the strip by using three potentiometers which are assigned red, green, and blue. The used should be able to switch between each mode by holding down the corresponding button.

Video:

https://youtu.be/_H2hzCIIstA

Supplies

Bill of Materials

Teensy (4.0) microcontroller

Electret Microphone Amplifier

ALITOVE WS2812B Individually Addressable LED Strip

ALITOVE 5V 15A AC to DC Power Supply Adapter

TWTADE 3PCS 10K Ohm Linear Taper Adjustable Rotary Potentiometer

6 in. X 24 in. ABS SDR-35 Riser Pipe

Jumpers

Circuit Board

3d PLA printer filament

Hot Glue

Arduino Starter Kit

Project Files

Project Functionality

Picture2.png

The project has four modes each assigned to there own button and the user should be able to jump between each state with the hold of the respective button. The spectrum analyzer is the starting state and displays the input audio on to the LED’s based on there frequency and volume. This state is best used with music at a reasonable high volume with the speaker or source of the music about a foot away. The farther it is away from the mic the less it will display and if it is too close it will just light up the entire strip so make sure to find a balance that fits your area and situation. The other states are fade, a random color print, and the potentiometer controls. The potentiometer controls are used to manually change the color of the strip if the user wanted to display a solid color.

Circuit Diagram

ET 370 Project Diagram (2).png

Please note that some things are represented only in the picture and not in the physical project. This will just show how the circuit is set up. For instance, the power source is NOT an 9V battery and the Arduino UNO is a Teensy 4.0 with the same respective pins.

Voltage, Current, and Power

The power supply provides 5V which allows for 0.2W per LED or 12W per meter which means the entire 5-meter strip uses about 60 W of power. The Teensy 4.0 is capable of the 5V and the mic ranges from 2.4-5.5V. The 3.3V pin from the Teensy is used in the project. The current to the strip is about 0.004 amps based upon these numbers. It is important not to supply more than 6V to the stirp or it will damage it. The power supply used is a 5V, 15A, and 75W supply. The most important thing is to NOT supply more than 6V to the strip.

​Logic Machine Diagram

Picture3.png

The user should be able to go to each state by holding the corresponding button. As of now the buttons are:

1.Spectrum Analyzer

2.Potentiometer control

5. Fade

6. Random Print

State 3 and 4 are different versions of the spectrum analyzer that were being worked on and are not included.

Code Snippets

State 1, FFT

The code starts off in state 1, which is this FFT code, and takes in an audio signal through the microphone and separates it into four different parts. The program separates the frequency into bass, mid-range, treble, as well as the decibel level. The bass dominant tones are displayed on the bottom of the strip in reds and oranges, mids are in the middle as greens and blues, high notes are at the top in purples, with the decibel level controlling the brightness. To get to another state from any of the four states, you simply press the state number you want to go to on the number pad and it puts you into that state. If you would like to learn mode about the Fast Fourier Transform and the spectrum analyzer please vist https://learn.adafruit.com/fft-fun-with-fourier-tr... . This is where this states code is from as we just changed a few variables to better suit our project.

State 2, Potentiometer Control This state uses three 10k potentiometers to control the red, green, and blue portions of the strip respectively. By fine tuning the potentiometers you can achieve the exact color you desire as well as turn the strip off when all three potentiometers are adjusted to their maximum. Take the analog value of the potentiometer (0-1023). Divide it by 4.02 so that this value is between 0-255 the division for 4.02 prevents the value from exceeding 255. The rest of the code will display the value to the LED's using pixels.show.

int redColor = analogRead(1) / 4.02;
int greenColor = analogRead(2) / 4.02;

int blueColor = analogRead(3) / 4.02;

State 3, Fade Between Colors The fade starts as blue and fades through all colors of the rainbow in a loop until another state is activated by the number pad. The code below repeats for each of the colors

//start from blue
for ( int colorStep = 0; colorStep <= 255; colorStep++ ) {

int r = 0;

int g = colorStep;

int b = 255;

// Now loop though each of the LEDs and set each one to the current color for (int x = 0; x < LED_COUNT; x++) {

leds[x] = CRGB(r, g, b); }

// Display the colors we just set on the actual LEDs

delay(10);

FastLED.show(); }

//into green

for ( int colorStep = 255; colorStep >= 0; colorStep-- ) {

int r = 0;

int g = 255;

int b = colorStep;

// Now loop though each of the LEDs and set each one to the current color for (int x = 0; x < LED_COUNT; x++) {

leds[x] = CRGB(r, g, b); }

// Display the colors we just set on the actual LEDs

delay(10);

LEDS.show(); }

State 4, Random Color Generator The random color generator works by generating a random set of numbers that are then set within the range of 0-255 for usable RGB values. Once the values are in the usable range, the strip regularly updates with the new color every time the int delayval which in our case was 1 millisecond. After the updated color is sent to the strip, a new set of values are generated, and this loop repeats until another state is entered.

setColor();

for (int i = 0; i < NEO_PIXEL_COUNT; i++) {

// pixels.Color takes RGB values, from 0,0,0 up to 255,255,255

pixels.setPixelColor(i, pixels.Color(redColor1, greenColor1, blueColor1)); // Moderately bright green color.

pixels.show(); // This sends the updated pixel color to the hardware.

delay(delayval); // Delay for a period of time (in milliseconds).

// Serial.println(i);

if (i == NEO_PIXEL_COUNT) {

i = 0; // start all over again!

setColor(); }

}

}

CAD Drawings

ET 370 Picture 7.png
ET 370 Picture 8.png
ET 370 Picture 6.png

Manufacturing/ Assembly

Picture4.png

Use the circuit diagram as a map to see how each component is wired together. In terms of the physical build here are a few tips. Before gluing the pipe to the 3D printed base make sure the potentiometers are feed through the holes so they can be hot glued after. The same concept goes for the LED strip as there is a cut out in the top of the base to run them through. When revolving the LEDs around the pipe there should be a 2- 2.5-inch gap between each pass. This should give a relatively uniform height to reach the top of the tube. The physical circuit should be able to be housed in the base under the tube with the microphone exposed and placed closer to the back opening. Once everything is in place hot glue the tube to the base. It should be able to rest in the curve of the hole but not slide all the way in.

Conclusions and Takeaways

For the physical project it is recommended to find a better way to hold the project together rather than hot glue. Hot glue works fine it is just a little fragile. In terms of code, it would be beneficial to find a way to break out of each state with a push of a button rather than holding the wanted state until the current state is completed. Also invest in a betted keypad as the one in the Arduino Started Kit is not of the best quality since some of the buttons stick to the back and do not lift. The project turned out great, but these are the few things to make it even better.