Introduction: Rainbow Audio-Reactive Flute

About: Just a guy who likes to make things!

Hello! In this instructable I will be showing you the process of creating this audio-reactive, rainbow flute (known as a Bansuri). The flute has RGB LEDS inside and will change it's color based on the note played. Note that this project requires a 3D printer, as you need to print the flute, as well as a soldering Iron to assemble the electronics. The rest of the project supplies can be bought fairly cheaply, and all in all is fairly easy to assemble. Without further ado, here's how you can build it!

Supplies

All supplies are purchased from amazon, but you can find your own replacements from cheaper vendors if you are willing to look.

Flute Body:

  1. Clear 3D printer filament (PLA):https://www.amazon.com/gp/product/B07ZNG4L9P/ref=p.... This Filament is PLA, which means it prints on basically all 3D printers with no upgrades needed, and gives a decently clear look. If you are able to print the body out of PETG, i have heard that that can be even clearer, but it does require a printer than can print at high temperatures.
  2. Hot Glue Gun: https://www.amazon.com/Hautton-Upgraded-Professio.... I prefer a glue gun with a longer nozzle as it is more precise, but you can use any one you have lying around, as long as you can be fairly precise with it. A good hot glue gun will help on many projects!

Flute Electronics:

  1. Neopixel Strip: https://www.amazon.com/dp/B00ZHB9M6A/ref=emc_b_5_.... These types of LEDs are super useful for many projects, and are often called neopixels because of the adafruit neopixels. Regardless, you can purchase these, or simply buy the adafruit neopixels if you prefer. Make sure to buy a strip that can be cut into smaller pieces.
  2. Arduino/ Microcontroller: https://www.amazon.com/ELEGOO-ATmega2560-ATMEGA16....You will need some kind of microcontroller that is capable of providing power to the LED strip, as well as controlling the LEDs (through PWM) and receiving analog input (for the microphone), I used a knockoff arduino mega, but an UNO should also work. If you want to get fancy, you may be able to use an ESP32 board as well.
  3. Microphone:https://www.amazon.com/Adafruit-Electret-Microphon.... These electret microphones are quite handy for many projects requiring sound. Make sure to get ones that have the amplifier built in.
  4. Assorted Leads: https://www.amazon.com/gp/product/B06XRV92ZB/ref=....Use various leads and wires to connect the components, always useful to have these around for electronics projects.
  5. (Optional) 9V battery and arduino connector: https://www.amazon.com/5pack-Battery-2-1mm-Arduin....If you want the project to be run without plugging the Arduino into the computer.

Step 1: Step 1: Printing the Flute Components

The actual flute design is taken from https://www.thingiverse.com/thing:2829717 (props to the designers!). You will also need my specific files for the modified end of the flute, and the small microphone holder, found here: https://www.thingiverse.com/thing:4559030. Print the flute body pieces 2-5 as well as my end cap. I used a layer height of 0.2, with support, and an infill of 20%. A low infill leads to more clarity in the flute body, and more light will shine through! Use whatever setting on your printer seem best. Also note the print orientation in the image above, which may help achieve a more stable print for the flute pieces.

You can also print the small microphone holder and, optionally, a case for your Arduino if you want things to match (https://www.thingiverse.com/thing:99710). Print these at a lower layer height, about 0.15. On my stock Ender 3, the prints all came out well, but took many hours to complete. If you print continuously it may take you 20-25 hours in print time.

Step 2: Step 2: Assembling the Electronics and Running the Code

Assembly:

It is important to assemble the electronics outside the body before mounting them to the flute. Follow the Fritzing diagram above to note the connections between the electronics components. Note that you will need to cut the LED strip to a length of ~30cm to fit inside the flute. You will also need to solder wires onto the exposed copper pads on the correct side of the cut LED strip. See this guide for more details https://www.instructables.com/id/Soldering-RGBW-an..., as well as the official Neopixel documentation for more info on Neopixels in general https://learn.adafruit.com/adafruit-neopixel-uberg...

Code:

The code is linked in on my github: https://github.com/yohancsx/ProjectCode/tree/maste.... You will need to install a few libraries as dependencies, namely the FastLed library, and the Arduino FFT library. This can be done by accessing Sketch -> Include Library -> Manage Libraries -> in the arduino editor (tutorial here https://www.arduino.cc/en/guide/libraries), and searching for the needed libraries in the search bar and then clicking install. The code is fairly well annotated, so please read through the comments to get a better idea of what it does and what you can change.

In summary, the code will take an analog input from the microphone, and listen to it for a short amount of time. It will take these samples and run an FFT to get the frequencies of the signal. Then the dominant frequency will be found. This is translated into a color by using the FastLED gradient functions and then sent to display on the LEDs. This process is not instantaneous, as it takes some time for the FFT to gather samples and run. You can mess with some of the parameters to acheive different effects, and even use your own gradients to customize the look of your flute.

See the documentation on gradients here https://github.com/FastLED/FastLED/wiki/Gradient-c..., and learn more about the awesomeness of the FFT algorithm here https://www.norwegiancreations.com/2017/08/what-is...

After connecting all the components, and running the code, you should be able to play some tones (https://www.szynalski.com/tone-generator/) , and see the LEDs respond to the music!

Step 3: Step 3: Assembling the Flute

Now comes the final step of assembling the flute. The most important thing in this step is to make sure the LEDs are still working as you assemble the flute(you can keep them on as you assemble the flute), and making sure that no air is leaking out of the flute joints. If the seals on the joints aren't complete, the resonance of the flute will suffer, and it may be difficult/impossible to play. To actually assemble the flute perform the following steps:

  1. First feed the wires from the LED strip through the end cap, use some hot glue to seal both ends of the small hole so that no air can escape through the hole that the sires are feeding through. See the pictures above for reference. Both ends should be sealed with a small amount of glue.
  2. Peel the sticky payer off the bottom of the LED strip if you have one that comes with adhesive attached to the bottom, otherwise you can put a very small amount of glue in a line along the bottom of the LED strip
  3. Put a small bead of glue around the lip of the next flute part, try not to put too little, or there will not be enough of a seal, too much and there will be excess glue inside the flute body. Once you have the glue on the lip, press the next flute part into the previous part (you may need a slight rotation to get the parts aligned)
  4. Quickly press the LED strip so that it sticks to the bottom of the inside of the flute (the strip should line up directly opposite of the holes). Inserting a finger (or other long object) into the flute and pressing firmly on the portions of the LED strip with the copper pads (between the actual LEDs) helps the strip adhere to the bottom of the flute.
  5. Repeat steps 2-4 for each segment of the flute. Refer to the pictures above for some insight on how the flute should be assembled. (note that the images above are of a slightly different design without the lip, but the idea is the same)
  6. Assemble the small microphone clip by placing the microphone inside and putting the small plastic cover over. It should fit snugly. You can then connect the microphone from the bottom using the connectors.
  7. It is useful to lengthen some of the wires so that you can play the flute more freely. I lengthened some of the wires, and added some tape in between to make sure the connections were solid.

Once you have finished assembling the flute, try and play it! You should be able to get some notes out, especially if you are only covering 3-4 holes, check this video for more details on how to play:

If the flute is still not playing, you may have to add some extra glue around the outside of the segments to complete the seal.

Step 4: Step 4: Complete!

Done! You should be able to play and dazzle others with the sound and sights of your flute. See the video for my test run (sorry for the vertical video -__- ).

Note that the fundamentals of this project can be applied to any type of audio reactive instrument. You can just transplant the electronics on whatever object you want to light up with sound. I hope that you enjoyed building this instrument, happy fluting!

Colors of the Rainbow Contest

Participated in the
Colors of the Rainbow Contest