YET ANOTHER... sound from a guitar output to power LEDS question

I know there are many here, and I've been searching for a while, but haven't found much that has been of any help, and wondering if the experts here can point me in the right direction.
The closest post I can think of that I am working with so far is Dance party light:Adressable led strip controlled by software soundwave analyser

Now.. I know NOTHING about any of this, and yes I'm a complete newbie and don't even know how to hold a soldering iron, never mind program this thing.. so flame on, but I'm here to try learn if people are willing to try help.

I recently (17 days age) made my son a new guitar for his birthday, and my wife came up with the idea of adding lighting affects like the old 70's colour organ.
There are tons of posts on the net, most of them 10 years or older available, and I bought an arduino starter kit, some WS2812B LED's etc and have been playing around. I have a simple setup working.. but of course I want to make it better.

My idea is to feed off the output jack of the guitar, and capture the audio and based on volume, frequency, tone, whatever, and the arduino powers up some of the LED's, which are built inside of the guitar and will shine through. It doesn't have to be terribly complicated. Just something that when he strums some leds light up for treble, others for bass, and brightness is on intensity.. or.. whatever.

The guitar has active pickups, so does have a 9V internal battery, it has a preamp built in (which he can enable or disable).

So.. if any of the amazingly smart people here have some ideas for an old fart who is trying to do something for kid... please let me know what you would suggest

Cheers and thanks in advance
Semi

Sounds fantastic but sorry to inform you that you will not be happy with the results. A 9V battery is great for smoke detectors etc but it cannot supply enough energy to run the Arduino and the lights for any length of time. I would suggest you add an external power supply and run a second wire to the guitar. Also be aware that the Arduino generates RF noise which will probably picked up in the magnetic pickup used to capture sound. The LEDs will also probably do this. Try with the leds internal and the electronics external and see what you get. I cannot predict what will happen as I do not know the details of the environment or the properties of the guitar etc.

I came across these rhythm lights, they may do what you want. If not they may give you an idea of something that would work. I used "LED color organ" as a search term and found this.

1 Like

Hi @gilshultz

Thanks for the reply.

So... I was half expecting that regarding the battery life. So his guitar has 2 which can be changed with a button press (hidden in the tail of the Flying V). They are also not normal 9v Batteries and have around 200 hours life each. (Fishman PRO-BPK-101 batteries).

My son is also only 13.. so even 30 minutes is the limit of him playing on stage at the moment :innocent: its more for the cool factor right now for his first band performance in 4 weeks.

I could also use one battery to power the active pickups, and the other for the LEDs/arduino. But I was worried about electrical feed back of some kind and hence why I am here asking for advice. My only understanding of a resistor 3 weeks ago was my wife blocking me from going out for a beer.. so it's been a big learning curve.

I also had massive issues with RF on his first guitar, but these are active pickups now.. and just in case.. all the internal cavities are shielded with copper tape.. so.. I am hopeful.. but of course it is all new territory for me

For reference as well, the guitar is 3d printed ...
so its pretty much hollow, its light.. and I have lots of space to move things around the internal cavities (Photos of internals was during design phase before I coppered everything up)



o

What you're talking about would be possible, but it would really be quite an involved project. There might be other ways to go about it, but I imagine a general overview might be:

  • Build a pre-amp circuit from dedicated electronic components
    The signal from even an active pickup is likely to be quite low (less than 1V). You would probably want to amplify it closer to 5V, to get a better quality reading with your Arduino. A simple form of this may use an "OP Amp" chip. Unfortunately it is beyond the scope of a short reply here, but I'm sure there some good resources around to look into the basics of circuit design. Falstad.com has a good circuit simulator to play around with ideas before committing to a build. You would ideally use an oscilloscope to confirm that your amplifier circuit was producing voltages at the correct level. Even if it turns out that the guitar output is strong enough to not need amplification, you would still need a piece of dedicated circuitry to add a "DC offset", otherwise the AC signal from the guitar will be sending negative voltages to the Arduino, which may or may not be a problem.
  • Use the arduinoFFT library to perform a "fourier transform"
    This technical sounding phrase, as best I understand it, refers to a technique for analyzing a (sound) wave, and breaking it down into component frequencies. This way you would have access to the relative "loudness" values of the bass and treble. You could use these in your code to control the LED to suit your vision. The arduinoFFT library takes care of a lot of the heavy lifting here, but you would still need to write some fairly intimidating code to get it all set up.

If your intention is to then build this all into a small circuit, to mount in the guitar, you will want to look into taking your prototype, and miniaturizing it onto a circuit board. A good step here would be to first test your design on a development tool known as a "breadboard".

What you are interested in doing is absolutely possible, and is the sort of project that I can definitely imagine being proudly shown off by people with a few years experience.

I am very impressed with your guitar builds, and while I think what you're hoping to accomplish might a bit ambitious right now, electronics is a rewarding hobby, and I encourage you to stick with it because I'm sure you will find interesting ways to incorporate it into your projects, right from the learning phase.

As for the goal of this specific project, maybe you would be able to find a ready-made commercial product that is suitable? Without naming names, some of the large Chinese online-retailers have a seemingly never ending selection of small electronic modules.

Alternatively, you might consider using an Arduino accelerometer module? Rather than changing your LEDs with sound, you would be changing them with the physical movement of the musician playing the guitar. This would be much more achievable.

1 Like

Can you post a link to the technical specs of the pickups and preamp circuits? It's important to know the signal characteristics (voltage, impedance, AC/DC etc) before connecting anything to an Arduino input. The analog inputs of Arduino are not "analog audio" compatible. Analog audio is AC, which can damage an Arduino input. It is also only 1V peak-to-peak, I think, which is quite low for an Arduino. But is the guitar output similar to this even with the preamp switched off?

An idea I had was to use an msgeq7 chip. This might mean that no op-amp would be needed, no AC-DC conversion and no FFT library, because the chip performs these functions. But I don't know enough about guitar pickups and preamps to know if it would be suitable.

That's 200 hours powering only the active pickups and maybe the preamp?

This page describes them as

Featuring a current capacity similar to a premium 9-volt alkaline battery

That's maybe 1200mAh

That would run the Arduino alone for about 30 hours.

You don't say how many ws2812 LEDs you plan to use, so lets assume 10 of them. The battery would run 10x ws2812 for about 2 hours.

Most Arduinos and ws2812 LEDs run on 5V. If you use a 9V to power them through a linear regulator, almost half the battery power will be wasted as heat, and keeping that regulator cool will be difficult. So I would recommend a "buck" regulator/DC-DC converter to reduce that voltage to 5V more efficiently.

1 Like

Hi @toddnz

I was assuming this would be complicated.. as soon as my wife said it should be easy :innocent:
I'm having a look at Falstad.com and playing around, thank you for that!
I'll take a video later of what works so far.. but I haven't turned the pre-amp on with the fear of what I have read here so far ( I have been testing on the Mega with a bread board.. But still have the Uno-R3 and Nano in their boxes for when I blow the Mega up)

I have also seen many posts about the DC->AC offset and negative voltages, but my limited understanding of how they were connected made no sense (as in splitting from one part to two, how does that work? )

My father was an electrical engineer and I never cared for what he did.. yes.. I know.. Now that he is no longer with us.. I wish I had spent more time listening. So far, its been amazing!

I'll also look at the "commercial" options, but so far I've struck blanks.. lets see.

Please don't try dripping solder onto the items you want to weld. :wink: Watch some videos and practice with scrap materials. I find soldering to be quite zen actually.

1 Like

Hi @PaulRB

So basically, it would be similar to EMG Pickups / KFK Set / Electric Guitar Pickups, Bass Guitar Pickups, Acoustic Guitar Pickups at the moment. (instruction PFD https://www.emgpickups.com/pub/media/Mageants/k/f/kfk_0230-0105rb.pdf: diagram 5)

The "pre-amp" would be this EMG Pickups / PA2 / Electric Guitar Pickups, Bass Guitar Pickups, Acoustic Guitar Pickups .. but I am really not sure if that even helps

My kids first concert wont be more than 45 min, so I am HOPING that should be enough. After that, I am pretty sure I will spending countless hours how to make that longer. But even 1 hour should be amazing.. actually.. even 15 min would be great if I can work out how to only turn the LED's on when he has the pre-amp on, which would mean he is playing solo?

And now.. i'm going to be googling what a "buck" is :smiley:

HAHAH mate.. I'm a research Scientist and a SysAdmin (but Linux and bash.. know enough to program.. just enough to blow electronics up) . So I've been watching LOTS of videos. But I think I was about 9 years old when my Dad turned around to me (after spending weeks trying to teach me how to solder), and said... Maybe electronics is not for you.. 35+ years later.. and I'm still scared

Someone did a similar project recently and they had trouble with noise. The active pickups might help but you've still got a pick-up coil.

So although it would be super-cool to have the LEDs in the guitar, I'd make the lighting effects separate. You could possibly build the lighting effects into the amplifier but I think you are better-off keeping the lighting electronics completely separate from the audio electronics.

There are "other ways" of controlling LEDs instead of using the WS2812's that could be less electrically noisy. Each WS2812 LED is chip with an oscillator and that generates lots of electrical noise. But the WS2812 (and similar) make it super-easy to have multi-color individually-addressable LEDs so they are hard to beat.

You probably will need a preamp to boost the voltage by a factor of 5 or 10. The built-in preamp for the active pickups is mostly a current-amplifying (impedance lowering) amplifier and it doesn't boost the voltage or "loudness" that much. The lower impedance greatly reduces the noise sensitivity past that point, so the guitar cable, etc., shouldn't pick-up hum.

But you might get enough signal without the preamp. If you scroll-down on your link above to my "World's Simplest Effect" post, you'll see a bias circuit. That will probably work as-show with the guitar in active mode or you can increase the resistors to about 1M and it should work directly from the pickup. You can comment-out the print statements in the code to see if you're getting a useful signal (and you can see if the LED is flashing as expected).

If you built a preamp, it's output also needs to be biased because the Arduino can't read the negative half of the AC audio signal. It can actually be damaged by negative voltages or the audio can be "damaged" (distorted). It's not too hard to build a guitar preamp with an op-amp but I don't have a link to a schematic with bias.

Another option is to run the lighting effects from the amplifier's speaker signal, and then you don't need a preamp. But, there a couple of "considerations". A regular guitar amplifier has too much output voltage. That's easily taken care of with a voltage divider (2 resistors). Resistors that add-up to about 10K are good.... It's the ratio that's important.

And since you probably don't know the voltage out of the amplifier and just to be extra-safe, you can add a pair of protection diodes. (The protection circuits show a current-limiting resistor but the resistors in the voltage divider take care of that.)

The other consideration is that voltage will vary with volume. So you may need to add a pot for sensitivity adjustment. And/or you can study my "Simplest Effect" code... It has automatic sensitivity adjustment (by using a moving average) and it can handle a pretty wide range.

With ANY project it's best to "develop" the input (sound input in your case) and output (the LEDs in your case) separately. Make sure you can detect the sound and get "good numbers" for the loudness and frequency, etc.

And make sure you can address-control the LEDs with just the software.

Then you can "mix" the two parts.

And once you can control LEDs it's just a matter of software to change the colors or patterns or whatever so you can add variations or randomness, etc.

If you don't want to fool around with the FFT software library for frequency analysis there is a special chip called the MSGEQ7 that gives you 7-bands of frequency information. The electronics is a little more complicated and the software is a LOT simpler. (With software you can get more frequency bands.)

FFT and addressable LED control are both "software intensive" and taking care of the frequency analysis in hardware allows your software to focus on controlling the LEDs. But, people make nice spectrum analyzer effects with a basic Arduino so that's not necessarily a big deal.

...The MSGEQ7 is misnamed as a graphic equalizer chip... It's not... It's a spectrum analyzer chip.

I built a color organ from a kit back then! After a couple of years and after I learned a little more electronics I was getting bored with it and I converted it to an effect that "popped-up" random color patterns on the beat... well.... approximately on the beat. There was always at least one color on, even with silence.

And, I'm still fooling around with this stuff! A few years ago I was thinking about making a giant VU meter but I wanted to add another sequencing effect. The electronics were getting really complicated (on paper) and then I thought about using a microcontroller and I found the Arduino. Then once I had something I could program, I created 7 different effects that can run randomly for about 1 minute at a time (or I have a switch to lock-in an effect). And all of the effects have random variations... The VU meter can be reversed (so louder goes down), it can be inverted so more LEDs go off when it's louder, it can be "mirrored", going both directions from the middle-out, and there are bar-graph and "dot" modes. It doesn't have any frequency sensing... All of the effects just work on "loudness" or the "beat" and it's only got red LEDs. But there is enough variation and random unpredictability to keep things interesting. I have "plans" to do something with RGB LEDs but I'm not planning on anything with frequency.

I've made some other effects using colored floodlights.

1 Like

I did have a quick play around today with the GY-521 gyroscope / accelerometer module. I didn't get a chance to go back and really get the sensitivity right, but I do think there's a viable option there, if the audio processing route becomes too frustrating.

The accelerometer is more than capable of detecting the beat / pulse when the guitar is strummed. It also seems sensitive enough to detect the general "loudness" of the sound produced, at least on the acoustic guitar I tested.

In addition to this, you have the gyroscope reporting the musician's spatial orientation. There's the option to adjust the LEDs based on the direction they're facing, or based on how high the guitar neck is raised.

I remembered earlier that I should also mention TinkerCad. Maybe you've already encountered the site at some point through your 3D printing? In addition to their 3D design tool, they also have a very accessible "circuit simulation tool". Admittedly, the target audience is younger than that of Falstad, but it has the benefit of supporting Arduino code. I think it has a wide enough range of basic components to let you experiment with amplifier designs.

AC means the voltage is going positive and negative. i.e. 90% of the time the negative battery terminal or power supply terminal goes to ground (which can be just a common reference connection, it's not necessarily an earth ground). But you can reverse the connections and connect the positive terminal to ground and now the voltage on the other end of the battery is negative (relative to ground).

This isn't always necessary but a lot of audio circuits use bi-polar power supplies with positive and negative, plus ground. Or occasionally they will use two 9V batteries, one for positive and one for negative.

The Audacity website shows an audio waveform going positive and negative (and it shows how it's digitally "sampled" to get digital data).

When the signal going to a speaker goes positive the speaker (usually) pushes-out and when it swings negative the speaker (normally) sucks-in. If you had DC bias on a speaker (which you NEVER want) the speaker would be pushed-or or sucked-in and the audio would vibrate it in-and-out relative to the bias.

...The analog-to-digital converter in a soundcard can read positive and negative voltage but the Arduino can only read positive.

The bias circuit combines the AC audio with DC and it moves the waveform "up" so it's (hopefully) always positive.

The Arduino UNO has a 10-bit the ADC (analog to digital converter) giving it a range of 0-1023. With the default 5V reference, 0 Volts reads zero and 5V reads 1023.

Two equal-value resistors make a 50/50 voltage divider. Connect it between 5V and ground and you get 2.5VDC.

Capacitors in series "block DC". The capacitor keeps DC voltage out of the connected audio circuit and it keeps the audio circuit from messing-up the DC bias.

Now the ADC will read about 512 with no audio. With "quiet" audio the reading will go up-and-down around 512. With louder sounds it might cover the whole range with the negative peak hitting zero and the positive peaks hitting 1023.

Note that the raw readings will "look random". Typically you need to find the peak or the average of the absolute values, or RMS, etc. If you use the MSGEQ7 or the FFT library you don't have worry about that.

You can subtract-out the bias to get positive & negative numbers. If you use the FFT library (I've never used it) it should take care of that automatically... FFT gives you the frequency bands and DC is "zero Hz" so you can simply ignore the lowest frequency "bin" if that's not done automatically.

The MSGEQ7 datasheet says it has some gain. And the input is high-impedance and it accepts AC in so you don't need a bias circuit.

You can find boards and even an Arduino "shield" which would simplify (but not eliminate) soldering.

Electronics and programming are both abstract... You can't see electricity, you can only see its effects.

1 Like

Thanks everyone.. Lots of reading and things to do :slight_smile:
I've ordered some MSGEQ7 chips, but it will take a week or so to get here, and in the mean time, i'm hoping to get some time to play around today.

Look at the bias circuit from @DVDdoug's post above for the "Worlds Simplest Effect", I need to ask how does that work? My simple understanding of DC voltage is that the charge flows between two poles. But looking at that it looks like it has 4? 5V comes in and goes across the two resisters and the audio across the capacitor to the input? :innocent: how?

I've been reading up a bit on https://electronics.stackexchange.com/ .. but maybe I should get more coffee!

And thank you

I have used tinkercad before, but never the circuit parts.

I was playing around now and then decided to draw it in tinkercad. and pretty impressed that I get the same values on the serial monitor as I do with the guitar.

This pretty much what I have done now, just with the bias circuit to test.. hope its correct :wink:

and nope.. I think thats wrong haha.. I found another post Audio input signal amplification - #4 by jremington and the breadboard there is different.. so I guess its back to reading up

So I think have the bias circuit sorted.
At least it now sits at 511 when reading in, and from https://docs.arduino.cc/built-in-examples/basics/ReadAnalogVoltage it is sitting at 2.49V. Strumming the guitar causes to peak at around 3.5V, and sometimes it drops to 1.5V.

Once I had an idea of what was going (or half) from @DVDdoug's "World's Simplest Effect" (which seems very far from simple to me!, I went and modified this Code | Trinket Sound-Reactive LED Color Organ | Adafruit Learning System and have a semi working setup (and I even soldered my first LED'S! WOOHOO)

I'll have to wait for the MSGEQ7 now to play and then find out how to wires this all together so it fits in the guitar.. since I cant put the breadboard in there.

Thanks so much everyone, its far from finished.. but a massive step forward..

1 Like

I was thinking about the remote, you could use the indicator on the wireless receiver to trigger your lighting. Use a CDS cell or other light sensor. When the remote body pack syncs that will cause the indicator to light, just sense that light with your arduino.

Hi all

So.. This I think is the best I can get with tinkercad to give an example of what I have done.
Of course, I cant seem to add a nano in there to work, but the pin layouts are the same

The schematic in tinkercad looks like this

And the simulation in tinker card works as I would expect (other than the voltage generator I put in there as I cant find a mic/audio input, seems to be exploding the capacitor in the simulation :wink: )

My final design will should more than one output to LED's (currently there are 4 strips of 10 all feeding off D6) and I am now watching tutorials on how to get this working correctly in Fusion 360 ECAD though I wanted to ask if the above schematic appears OK to you all? I know it works.. but yeah.. that doesn't mean much to me at the moment and I don't want it to explode while my kid is using it :smiley:

I did a trial test inside the guitar last night.. and I'm VERY happy with the outcome so far, now I just need to make it smaller, and then play with the MSGEQ7 chips that should arrive tomorrow.

3 hours later.. and that schematic from tinker cad looks so wrong now that I can read it a bit better after going through some fusion ECAD videos... Sigh..

Ok.. so the question I guess is, are the resisters and capacitor ok?