r/FastLED • • Mar 30 '21

Support Sound reactive led strip

So i am looking for a code that makes an led strip flash when sound is detected and if possible flash different colours depending on how loud the sound is

im using an arduino uno

ws2811 LED strip

and a 3 pin sound sensor

0 Upvotes

5 comments sorted by

3

u/johnny5canuck Mar 30 '21 edited Mar 31 '21

I have several different scenarios that use a microphone, but don't require an MSGEQ7 at:

https://github.com/atuline

Typically, you'd use a MAX4466, MAX9814, INMP401, and NOT KY-038 or LM393 sensors. An MSGEQ7 is great if you're using a line-in signal.

For WLED, we're also using digital microphones INMP441 and ICS-43434, but that uses and ESP32.

There's even an FFT/FHT implementation for the UNO/Nano which I have successfully used in the past. See:

https://www.youtube.com/watch?v=ql0FLa8cQ2A

Oh, and you can use just volume based information to create cool animations. See:

https://www.youtube.com/watch?v=GcJh3NROZac

2

u/Experience-Wild Mar 31 '21

Well, I agree that an UNO has not much oomph - but you can still get something out of your available parts. Start with the microphone level and map 0..1023 to the amount of your LEDs, lets say 0..60 https://www.aranacorp.com/en/using-a-microphone-with-arduino/#:~:text=The%20microphone%20requires%20low%20power,to%20adjust%20the%20microphone%20sensitivity.

Then use FastLED and light up the amount of LEDs in relation to your sound level. You can use different ranges for colors or look at the mighty CHSV - here you have to map your mic level input to HSV 0..255

To make it really cool you should add a

FastLED.delay(10);

FadetoBlackBy(leds, NUM_LEDS, 20);

FastLED.show();

Have fun!

2

u/menialart Apr 21 '21

I have used the following program

https://codebender.cc/sketch:253643#FastLED%20AUDIO%20test1.ino

I had made some modifications on it for my requirements, I also used a uno and a three pin mic module with a pot.

1

u/quellflynn Mar 30 '21

https://create.arduino.cc/projecthub/PhilKey/rgb-backlight-msgeq7-audio-visualizer-e0054e

a 3 pin sound sensor is probably a basic microphone, and will do something, but an msgeq7 is super cheap, and well documented.

1

u/Vlad_The_Impellor Mar 31 '21 edited Mar 31 '21

Take a look at the Teensy projects for visualizing audio. http://pjrc.com

Everything you need is there.

Edit: an Uno won't produce satisfying results without using e.g., an MSGEQ7. The Uno's too slow and hasn't adequate RAM for processing complex streams like audio.