Got FHT (variation of FFT) to work on an Arduino with FastLED.

Got FHT (variation of FFT) to work on an Arduino with FastLED. Put the code together from a couple of resources. Code:
Try it out!

Can now do audio-reactive blinkys with no MSGEQ7! Can’t tell the difference visually, but a much simpler control box schematic. I use 3 frequency bins, but you can change the averaging functions to make more or less bands.


Consider me interested – this sounds great! Please do share what you’ve created – I bet lots of people would be interested in this!

Indeed. How fast is it compared to the external chip solution. Appears it snappy on the spot or do you see/feel a latency?

I figured as much :wink: Already assembling some resources which I will post in comments here, then assemble into a document. Maybe even try to get it included in the FastLED base library? @Daniel_Garcia
It is snappy :slight_smile: I couldn’t believe the Arduino was capable

Stereo to Mono summer. Feed the single line out into an analog in on the Arduino. I use one so I can run just a single FHT function. If you’re adventurous try stereo and let me know how it goes!

In order to use the Infrared library, I need to use a 2nd Arduino and then transmit commands serially to the one running FastLED. Do you know if we can run FHT on the same Arduino as FastLED? Also, would that work on a standard UNO/Nano/Pro?

I run FHT + FastLED off of 1 Arduino Nano. Plenty of space left too on a ATMega328 version

You feed the audio AC directly into the Arduino?!

Yep. Don’t use a powered signal (post amp). From laptop / phone / mp3 player / mixer is perfect
Cleaning up some code now to put up

FFT/FHT Library available here
A big thanks to TJC!

The example in fix_fft didn’t work for me. This is a library that needs to be included to do the FFT/FHT. My example code coming up in a bit


Anybody want to try it? :slight_smile: Example code should cause LED strip to glow to bass.

I got an error: LED_COUNT was not declared in this scope. I just changed it to NUM_LEDS than it worked. quiet nice work. I used the adafruit electeret mic amp. It’s a nice effect and much more reliable than I had expected. It does though only work if the music is loud enough. Also it did detect a lot of false beats. Nevertheless I’m really impressed. That’s more than I achieved.

Oops thanks for catching that. Should be fixed now
There is a variable “baseline” which you can tune. This sets the threshold for whether or not a waveform triggers the effect pattern. And yes there will be some false beats. A lot of the time it’s finding a balance between too much sensitivity and too little, but same deal on the MSGEQ7 in my experience

Added some info about variables in the readme
To limit false beat detection, I sometimes will tune the variable ledTimer to limit how often the LEDs can be triggered.

I was just messing with ArduinoFHT this weekend. I’d love to see the code! Thanks :slight_smile:

@Shlomo_Zippel It’s posted, github link was hidden below the “read more” so i put it up top now

@Kev_Zhu Glad you added a bit about the variables in the readme, as the code is pretty lacking in comments.

I was able to get Kev’s demo running, but was unable to find where/how he stores FFT results, ie. an array with sound levels for increasing frequencies.

I did, however get better success with:

and wrote a quick demo that allows me to increase the frequency of a tone generator and have LED’s 0 through 14 light up sequentially.

Both seem to run on the order of 30ms.

The FFT results are in the value[] array
My 3-bin weighting is shown in the readme

OK, thanks. Didn’t know what a ‘bin’ was.