I was wondering how an illuminated music instrument might look like in the dark.
To allow for a certain dependence of the illumination pattern and the instrument's sound, audio spectrum analysis seemed to be a reasonable approach.
As instrument I chose a ukulele since there are DIY (do it yourself) construction kits available at a reasonable price and I had a crude idea of how to get the LEDs in.
Here a quick glance at the result: A concert ukulele w/ 3 optical elements (2 LED strips in the fretboard, 1 LED ring around the sound hole).
UPDATE 1: Meanwhile I built a 2nd (larger) LED Ukulele and added some burning fire effect, see below.
Ideas for the future:
- Use LEDs do display grip patterns for chords or even simple solo lines based on input from a mobil device wirelessly coupled. Update 2020-07-15: Stumbled across something like this here: https://www.instructables.com/id/LED-Ukulele-Level-One/
The Ukulele
It all starts with buying an appropriate DIY ukulele construction kit. The following aspects seem most important to me:
- "Size" of the fretboard. Since a certain mounting space for the LED PCBs and the wires is necessary, I went for a concert ukulele (aka "23 inch". Lenght of measure ~38 cm. The most common ukulele, the soprano ukulele, is definitely too small for this kind of project using the electronic hardware described below.). From my "theoretical studies" I thought that the width of the fretboard is ~4 cm at its smallest extent and the distance between the first 10-12 frets (which I wanted to use for displaying the result of the audio spectrum analysis) should also be ~>1 cm for the closest frets (i.e., frets 10, 11, 12). However, if I would repeat this project, I would probably go for the next larger type of Ukulele, i.e., a tenor ukulele, since it turned out that - probably due to manufacturing tolerances and my limited tool set and craftsmen skills - I was not able to follow my original plan. I needed more construction space to get all the LED PCBs in - or smaller LED PCBs. (The LED PCBs I used were about 9-10 mm in diameter and ~3 mm in height).
- UPDATE 1: Meanwhile I found a suitable "larger" (i.e., 23" aka tenor ukelele DIY kit. However it turned out that the width of the fretboard at its upper end is still too narrow to put 4 LEDs in line. Nevertheless it was possible to fit 4 LEDs w/i each of the frets 1 to 11.
- Make sure that you buy a DIY ukulele construction kit that comes with separated neck and fretboard (since in between you will have to put the LED PCBs). W/ respect to the fretboard make sure its thickness (typically 4mm) matches the LED PCBs you choose (in my case LED PCB heigth ~3mm) so that sufficient installation space is provided. Maybe getting 6 mm thick fretboard would also be a good idea mitigating some of the manufacturing challenges.
- Most of the DIY construction kits come along w/ rather poor tuning pegs. Those typically easily detune and so you might end up with a nicely illuminated but awfully sounding ukulele. So it might be a good idea to get appropriate tuning pegs along with your DIY ukulele construction kit. What do I mean by appropriate ? There are tuning pegs that basically are straight and other ones that go around by 90° (using worm gear and pinion) in the headstock of the ukulele. Latter ones I prefer. Both types are shown in one of the pictures below. Attention: There is up to my experience no standard for the diameter of the holes for tuning pegs in the headstock. So make sure you get matching ones. I was lucky since I had some old tuning pegs lying around at home which fitted well enough.
- Last but not least you also might want to get suitable strings, since the ones shipped with some of the construction kits are rather cheap, resulting in - again - frequent detuning and/or poor sound.
Electronics
Due to the limited space available (its a ukulele, not a guitar) I chose an Arduino Nano. Its memory and speed should be sufficient for the audio spectrum analysis and it works w/ the FastLED library used for control of the LED PCBs I connected to WS2812B type strips.
To get the ukulele's sound to the Arduino Nano I decided to use a brakeout board by Adafruit (Adafruit MAX4466 Electret Microphone) which records the sound using a broad band electret microhpone and allows adjustment of the gain. Therefore it is possible to adjust the input sound level to the Arduino (since I have no clue how the sound distribution w/i the ukulele's body looks like). Also the package is small enough to meet the requirements w/ respect to limited construction space w/i the ukulele. The 470µF capacitor between Aruino Nano's 3.3 V and GND serves to reduce noise in the 3.3 V power supply line (otherwise resulting in flickering of the 1st two LEDs in each LED strip in the fretboard. Just remove it in your breadboard test setup and you will understand what I am talking about.).
I also added a potentiometer that allows to adjust the brightness of the LEDs. This might come in handy to adjust the LEDs brightness to surrounding light level. Too bright LEDs might be disturbing in a rather dark room. Furthermore, in case your power supply runs empty or all LEDs are lit at maximum brightness, the voltage might drop to a level that leads to unstable operation of the Arduino.
A simple push button was added to facilitate selection of different lightning patterns/operating modes. This can be simply changed (e.g., new combinations added or removed) w/i the software. In case the push button is pressed during execution of the setup part of the code (practically just push it before you power your electronics) all LEDs will turned on and off once to provide a quick way to check functionality of the LEDs/connections to the LEDs.
Typical available LED strings (RGB, separately addressable) have equally spaced LEDs. Due to the changing distance between the fret bars this was not a useful approach for my project. I stumbled across single LEDs of WS2812b type (i.e., RGB LEDs, w/ on board WS2811 IC, see picture below) that can be easily controlled using FastLED library just as typical WS2812B LED strings. Make sure the height of these LED PCBs is appropriate for the thickness of your fretboard. Unfortunately I cannot provide a link to the seller since he does not offer such LEDs anymore. :-(
The rest ist wire, solder - and patience.... (Why patience ? 30 LED PCBs w/ 6 closely spaced solder connections each combined w/ limited tool set and craftsmen skills... you'll find out by yourself...)
Manufacturing Part 1: Add LEDs to the ukulele
The most crucial and uncertain part to me was whether I could manufacture the fretboard containing the LED PCBs, so...
...I started with marking the positions for the LED PCBs on the backside of the fretboard. After that I drilled some dimpels centered at the marked positions and just deep enough so that they can accomodate the LED PCBs from/into the rear side of the fretboard (~3mm in my case). Here a thicker (as above mentioned 6 mm fretboard) would have given me the option to provide some installation space for the solder and wires, however, I only had a 4 mm thick fretboard available.
This is when I also had to realize that especially in the upper, narrow part of the fretboard (frets 1 to 5) I could not achieve the necessary precision to put 4 LED PCBs next o each other w/i one fret. This is why I finally ended up with only 2 LED PCBs in frets 1 to 5 and 4 LED PCBs in frets 6 to 10 (giving a total of 10 + 20 = 30 LED PCBs).
Next, I glued the LED PCBs into the dimples using ordinary handicraft glue. Since the LED PCBs had 6 solder pads (2x GND, 2x VCC, 1x Din, 1x Dout), I decided on the orientation shown in the picture below. Pay attention to the direction of data flow ! Since there are 2 interconnected GND and VCC pads per each LED PCB, respectively, there is only 1 DataIn and 1 DataOut solder pad, so here the order/direction of connection / orientation of the LED PCB is important. The chosen orientation and alignment allows for straightforward connection of GND and VCC of each LED PCB.
Furthermore (due to the fact mentioned above that I did not succeed in having 4 LEDs in all the frets) I split up the LEDs in 2 seperate optical elements/strings. To save precious installation space GND and VCC for the 2nd LED string are connected directly to an appropriate position of the 1st LED string (thereby saving separate VCC and GND wires for the 2nd string).
Now the fretboard with the LED PCBs has to be mounted to the neck. If one is able to connect the LEDs with wires in a perfect straight line, one could think of milling channels for the cables into the neck. I also tried using copper tape, however due to the topology I did not manage to get sufficient electric contact.
However, as you can see in the picture below, in my case the wire connections are far from being lined up in a straight way. Furthermore, while the dimples could well accomodate the LED PCBs, the solder however reached out of those dimples. Therefore I decided to use some foam rubber ("Moosgummi") ~2 mm thick. I used multipurpose glue/handicraft glue to glue that foam ruber in between the fretboard and the neck. This is one of the most delicate manufacturing steps, since it is not reversible. Like in case you would just manufacture the ukulele (w/o any LEDs) using the DIY construction kit, you have to compress this triple stack (neck, foam, fretboard) for quite a while and with just the right pressure. Numbers ? No idea. Listen to the craftsman inside you. Also check out the video tutorials if you need information about how to put the pieces together to finally yield a ukulele.
I was quite happy to see that I could still control all the LEDs after this challenging manufacturing step. About the glue: I recommend to make some tests before you do the above mentioned non-reversible manufacturing step. Wood glue did not do the job in my case. It did not stick to the rubber foam. Another "office desk" glue I tried did not stick to the neck. Finally my wife came up with the right glue. Thanks! Also make sure your glue is neither conductive (this might short circuit some parts of the LED PCBs or cables) nor has aggressive solvents that might damage the LED PCBs. At first I was worrying that the foam rubber might decoule/damp the ukulele's strings vibration too much leading to a silent sound of the ukulele. This came not true, at least not to my impression (although I did not compare it to a 2nd ukulele manufactured based on the same DIY construction kit w/o optical elements and/or foam rubber).
After having achieved this, the assembly of the rest of the ukulele is pretty much straight forward. Tutorials, videos and alike can be found in the www. This is where I bought my DIY kit and they also link to tutorial videos: (https://www.kirstein.de/Konzert-Ukulelen/Classic-Cantabile-UC-240-DIY-Ukulele-Bausatz-Konzert.html?userInput=ukuele&ignoreForCache[]=userInput&queryFromSuggest=true&ignoreForCache[]=queryFromSuggest).
I also added a third optical element: An LED ring surrounding the soundhole of the ukulele. This LED ring has similar tye of LEDs (probably also WS2812B, but nit 100% sure anymore) and therefore can be controlled by same software routines as the two LED stripes in the fretboard. Details see software description below. My impression is that this LED ring does have an influence on the ukulele's sound. This is plausible since a string instrument's sound is - at least to my understanding - largely influenced by the vibration of the upper and lower part of the body. Currently I glued the LED ring to the body w/ double sided sticky tape. Maybe it would improve the situation if attach it only w/, e.g., 4 screws instead of the tape.
Manufacturing Part 2: add electronics & circuitry to the ukulele
The mounting positions I chose are shown in some pictures below. My boundary conditions were:
- Possibility to repair/bug fix hardware: Therefore all the components are fixed by screws (nothing glued or clamped or alike) to allow unmounting/disassembly. Also only 1 end of each cable was soldered. The other end was connected to the Arduino Nano using female jumper wire connectors.
- Arduino's USB connector should be easily accessible for future software updates.
- "Large area components" such as the microphone breakout and the Arduino Nano should be mounted to and fixed at the ukulele's body without any tilt (-> requires usage of surface of the ukulele's body with as little curvature as possible.)
- Push button for lighting mode selection should be easyly accessible during playing the ukulele.
- Wires (e.g., power and data to LED elements or power supply of the whole system) shoud not be where "moving parts" (i.e., the strumming or picking hand or the hand pushing the ukulele's strings onto the fretboard) wil be during usage.
While for some elements the mounting holes could be established simply by drilling, for other parts a combination of drilling and sawing had to be used.
Finally a few words about the power supply. Typically the WS2812B LEDs operate already at pretty low voltages between 3.5 and 5 V. While 3.5 V is too low for the Arduino to operate reliable, more than 5.something V will damage the LEDs. Since I wanted to use rechargeable batteries I decided to use 4x rechargeable NiMH accumulators of AA size. ATTENTION: In case someone puts in non-rechargeable batteries (which typically supply 1.5 V each) the power supply might then kill your LEDs. (I personally stronlgly dislike such a scenario since most of the work went into getting the LEDs into the fretboard. Any ideas for simple protection circuitry ?)
About current sonsumption: Assuming all 3 LED elements are fully lit at medium (~0.5) brightness and "half white" (i.e., mixture of various colors) and a single fully white lit WS2812B LED consumes 60 mA, a current of about (10 + 20 LEDs) * ( 0.5 x 60 mA) * 0.5 ~ 450 mA is necessary, which can be supplied by the batteries chosen. Cranking up the brightness (using the potentiometer) leads to significantly higher power consumption and sometimes (I assume) instable operation of the Arduino Nano (due to voltage drop) and "strange" or "stuck" lighting patterns.
The power supply will be attached to the backside of the ukulele's body by some hook-and-loop-fastener ("Klettverschluss") to achieve really mobile application.
That's it for the hardware. Anything else is software.
SoftwareI learned a lot about FFT and WS2812B LED control when trying to reproduce Antoine Rochebois project (https://create.arduino.cc/projecthub/AntoineKia/interactive-led-table-for-50-650b83?ref=platform&ref_id=424_trending___&offset=84) using an Arduino Uno.
So I basically plugged things together and modified a few parts and added a few lines of code. The comments in the code below should contain all the necessary explanations.
General
For each LED strip/ring a separate array is used (to allow easy access and programming).
Control (Hue, saturation and value) of each LED strip/ring is done by separate subroutines - which only differ in the names of the relevant variables (array name, number of LEDs in array and alike). This could probably be improved by using only 1 subroutine/function which is called w/ appropriate set of parameters. However I am not that experienced in programming, especially when it comes to handing over arrays to functions. And due to the limited number of LEDs luckily this is not necessary.
Setup
In the setup routine each LED is lit once to check if each of them is still working.
Main
In the main part, first the audio data is collected, followed by FFT.
After that the LED brightness is determined by evaluating the potentiometer setting. This as well as the audio data collection is done in the so called Free Running Mode of the ADCs in the Arduino by directly accessing the microprocessor's registers.
Next the lightning pattern is determined based on the number of times the push button was hit. (If button has not been hit, all optical elements are off !)
Finally the corresponding values are written to the LED arrays and everything is shown by calling FastLED.show().
Some final remarksWhile I still like the changing illumination of the ukulele while playing, I have the impression that the pattern is not really the result of an FFT. This might, however be a consequence of mapping the audio spectrum from 20 Hz - 20 kHz to only 2 (frets 1 to 5) or 4 (frets 6 to 10) LED bins, respectively. In addition each LED bin has a very limited height of only 5 LEDs. On the other hand it might be true that the sound prouced by the ukulele - epsecially after the project specific modifications - is far from sine waves, leading to broad band FFT response that makes it hard to see any differences for low or high frequencies played. Or maybe the stiff mechanical coupling of the microphone brakeout board to the ukulele adds some "mechanical" noise/vibrations/frequencies to the intended audio input. Something to maybe follow up in the future....
Nevertheless, I learned a few things during my project and the result still satisfies me. Construcive comments and improvement suggestions welcome!
Hope you enoyed reading this tutorial and it helps you in case you do a similar project
Good luck, lots of insight and especially fun!
Comments