# Audio input to Servo output, using... Arduino!



## Batbuddy (Sep 3, 2014)

So ever since I used MikkoJay's Prop controller setup last year I have been taken in by the Arduino and have been wanting to get the "audio to servo" bridge crossed. I want to have a way to do the stuff that the "Scary Terry" circuit does without the use of a bunch of components and custom circuits. Also to have more control and uniformity without having to do all of the goofy hacking that people do to get the "Scary Terry" circuit to work. (Lest anyone think otherwise, I am not bagging on the Scary Terry circuit, because personally I am impressed and have used it several times. I just want to advance the concept and make it better.) I am still working on this and it is NOT perfect or complete, but it is working and soon will be ready to have others try. I am excited that I got this far, being that I am not a programmer and have only been working on this for a few days. What this means is that in the near future I will have my three axis skull running on an Arduino system that is customizable, easy to work with and adaptable to all sorts of applications. Best of all it will require little in the way of custom circuitry.if he is open to it, I will hybridize this with Mike's (Mikkojay) controller.[ame="https://youtu.be/0ws063LpU00"]


----------



## mikkojay (Sep 15, 2014)

Hey Kenny, that looks like some fun stuff.
I have played around with the same notion but never saw anything through to completion.

I used one of these:









If you search ebay for LM386 module, you can find them for about a buck.

For sampling audio, I created a "ring buffer" using an array of sample values. I would always use an average of the samples to base movement on. This seemed to smooth out noise and random spikes of movement.

I cannot dig in too deep tonight, but I'll keep an eye on your project for sure!

-Mike


----------



## Batbuddy (Sep 3, 2014)

Hey thanks, Mike! I was wondering if there was any Ready made hardware, I make circuit boards a lot, but I know that there are many who would rather avoid that and so I want to make it easier for them. I'll look into this...


----------



## Batbuddy (Sep 3, 2014)

OK So I took Mike's suggestions and improved the code with an array and I improved the Op Amp circuit. Here is the progress video.


----------



## IMU (Apr 8, 2009)

Hey, this is something I'd be very interested in doing as well. Looks good so far. I don't think I would want to make my own circuit boards so if you have a setup that doesn't involve making one, I'd like to try one of these too.


----------



## toozie21 (Aug 23, 2012)

This might cause too much complexity, but if the audio was stereo, it might be nice to encode a second set of movements (eyes or head) on one channel along with the actual audio on the first channel. This way, you can encode two types of movements on one audio track. Just a thought, but I can imagine that it might over complicate things for you. Keep up the great work!

BTW, What are you using for the mouth in your second video? Is that a 3D printed jaw?


----------



## Batbuddy (Sep 3, 2014)

Hey thanks IMU and toozie21! Right now the way the movement is obtained from the Audio track is by turning the amplitude of the audio into an analog signal into the Arduino. Amplitude is the fluctuation of voltage in the audio signal. What that means, and what I want to achieve, is as much realism of movement with out having to do all of the hacky things folks have done to get the jaw to move better, like running a different channel that has high and low signals and meticulously syncing that channel to the talking audio using audio editing software. EDIT: I just re read toozie21's comment and I think I misunderstood. So in answer to toozie21, With the current configuration of this project you could simply play any talking audio track out to a different unit and send it to a separate servo. Basically hook up two separate systems to two different audio tracks and output that to two separate servos. I think that is what you meant. ? However, I am planning on including some separate servo outputs, on this same Arduino, with random movement for the use of animating a talking skull though. But I like your idea, I will think more about this... oh and The jaw is just something I made out of Plexiglas. I don't have a printer...yet. Also I looked into the little OpAmp circuits that Mikkojay mentioned above and they would have to be "hacked" a little to get them to work just right I think. At least a DC offset would have to be added, just a few resistors and maybe a capacitor, but they are very close to what is needed. I might get some PCBs made that have everything just right so that it is more like an Arduino shield, but that is still a bit farther down the road. The PCBs would be pretty cheap from China.


----------



## IMU (Apr 8, 2009)

I don't know what you just said but it sounds cool. I'd be happy with something more simple. Plug an audio source into one of these suckers and bam ... a talking skull. Maybe a split audio track that goes to two of these for a pair of talking skulls? Don't make it too complicated. LOL it took me way too long to get my 4 banger figured out and working.


----------



## Batbuddy (Sep 3, 2014)

Hehehe ok, ok. I used to not know much about this sort of stuff either, so I know what you are saying, but over the last 10 years or so I have spent most of my free time studying electronics and such. I will make it simple to understand once I have everything just right. As plug and play as possible.


----------



## toozie21 (Aug 23, 2012)

Ignore my ramblings, they aren't worth slowing you down . What I was suggesting would have made things more complicated, and I think we all agree that that isn't worth it!


----------



## IMU (Apr 8, 2009)

Thanks Batbuddy ... I'm sure I'm not the only one who would appreciate that.


----------



## ScaryLane (Jun 3, 2013)

Batbuddy said:


> I want to have a way to do the stuff that the "Scary Terry" circuit does without the use of a bunch of components and custom circuits.


I agree that "the Scary Terry" Circuit has too many discrete components and is not the best way to handle the jaw movement. I also try the op-amp tuned circuit system but it too would drift as the temperature changed.

The other problem is the lack of control of what frequencies to monitor for the best Jaw movement. With the standard op-amp design you can't stop the bad frequencies from effecting the jaw.

A bit over a year ago, the was a lot of chatter in the Arduino community about this little 8 pin MSGEQ7 chip. This one chip will amplify the audio level and break it down with a 7 band audio spectrum analyzer. Interfacing to the controller is easy. Just two digital outputs (Strobe & Reset) and one Analog input that ranges from 0 to VCC.

The chip is not badly price with it starting at $1.30 on eBay to a high $4.99 at sparkfun.com. Add in two Resistors and three Capacitors, you got a inexpensive circuit that gets the job down.

I'm using two MSGEQ7 in my Banshee project to drive Servos (Jaws), Lights (Signing Jack-o-lanters) and other stuff with the Audio from the on-board player. With the Automatic Gain Control in my software, there is NO jaw adjustments needed other than setting (Once) the Open and Closed position of the of the jaw Servo. Anyone that used the "Scary Terry" circuit will see what improvement the MSGEQ7 circuit is.

You can read more on the MSGEQ7 in "Sign Skulls" Article that I wrote in Last September's (2015) Nut's and Volts magazine or do a google search on the MSGEQ7.

Note: The Sign Skulls article used tones on three frequencies to drive three skulls that could only be open or closed. One audio channel supplied the tones and the other was the music track. Banshee uses the volume level to drive the jaw directly. So, a whisper will barely move the jaw for a nice effect.

I hope this helps.


----------



## Batbuddy (Sep 3, 2014)

This might be an idea to try, I do however want to avoid the concept of making a separate audio signal that drives the circuitry and ultimately is fed into the micro controller. To me the whole idea with sending an audio signal to control a servo movement is that it is plug and play. If a person has to manipulate the audio it would be better to just use other methods and write a control track that is more simplistic, I.E. Mike's Arduino prop controller. I like the idea of a simple splitting of audio frequencies to condition the audio in a live way, So thanks for the idea. I will have to look into these MSGEQ7's more... Sounds like the Banshee concept is more like what I am going for Vs the Sign Skulls.


----------



## IMU (Apr 8, 2009)

Still have no clue what you're all talking about but I hope you figure it out. :googly:


----------



## ScaryLane (Jun 3, 2013)

Batbuddy said:


> If a person has to manipulate the audio it would be better to just use other methods and write a control track that is more simplistic, I.E. Mike's Arduino prop controller. I like the idea of a simple splitting of audio frequencies to condition the audio in a live way, So thanks for the idea. I will have to look into these MSGEQ7's more... Sounds like the Banshee concept is more like what I am going for Vs the Sign Skulls.


The "Singing Skulls" was for a trio of skulls and its very hard to control with just two audio channels. (That's the reason for the tone track to drive the the three jaws.) The article was pointed out as a good source of how to interface with the MSGEQ7 and not so much as a way to control the jaw movement.

In the case of one or two skulls, the two MSGEQ7 on Banshee do a nice job of syncing the audio track with the jaw. All without the need of doing anything special to the audio track.

With that said, Banshee has the option to use one audio track just for the jaw sync and the other for the guest to hear. What way, you can have an audio track with other "stuff" other than the talking voice for a complete haunt sound track. Otherwise, the jaw would be moving to the sound effects or music on the recording.

The main reason I was suggesting the MSGEQ7 is the chip does a great job of amplifying standard audio levels to a voltage level that is usable by the analog input of an Arduino. (Much better than a standard op-amp circuit.) The fact of getting 7 band audio spectrum analyzer is just icing on the cake.

One last note, Don't buy the MSGEQ7 off of eBay. My last order had a 40% failure rate. SparkFun and Digi-key has the chip for about $5. It's a little high for my taste, buy there is no question that its a working chip. (Digi-Key shipping is a bit lower.)


----------



## Neil (9 mo ago)

ScaryLane said:


> The "Singing Skulls" was for a trio of skulls and its very hard to control with just two audio channels. (That's the reason for the tone track to drive the the three jaws.) The article was pointed out as a good source of how to interface with the MSGEQ7 and not so much as a way to control the jaw movement.
> 
> In the case of one or two skulls, the two MSGEQ7 on Banshee do a nice job of syncing the audio track with the jaw. All without the need of doing anything special to the audio track.
> 
> ...


I appreciate this is a very old thread, but I would be very interested to know what progress you made with the MSGEQ7, Arduino and servo control? Any update would be very appreciated.


----------

