Control Servo Using Microphone Frequencies

Hi,

I'm currently trying to create a project that 'automatically' sorts waste by the frequency of the sound it makes when dropped like the below video:

I've got an Arduino R3 and duinotech microphone XC-4438 as well as a servo motor from Jaycar: GWS Servo motor 3.4 kg/cm.

So yeah I want to program the servo to turn either left or right depending on the frequency, amplitude etc. can someone please point me in the right direction? Do I need to use Fast Fourier Transforms?

Many thanks.

Do I need to use Fast Fourier Transforms

Yes. FFT or FHT

Thanks for the reply.. Umm I just hit a major roadblock.. I found a 12V 1.5A DC adapter lying around that I tried powering the Arduino with instead of using the USB connection.. I had the USB connection in at the same time and tried powering with the adapter and now my computers are not recognising the Arduino at all...

Btw whilst I had both power sources in I could smell something burning a little bit, so I removed the DC adapter and the lights made some weird flickers. The lights currently turn on when trying to just use the USB but it's not getting recognised at all. Did I fry it or something? :S

Did I fry it or something?

Yes.
You did something other than you described. What you described would not have produced the results you saw.

All I did was plug in the 12V adapter.. The usb was plugged in first I think (Or other way around). I left it there for a while as it seemed fine, though I smelt something 5-10 minutes later so removed the 12V supply and that's when it made some weird light flashes I think.

Now when I plug it into computer both the green and orange light just stay on constantly?

There are lots of things that could be wrong with this. Was the supply AC or DC, was the polarity on the plug correct?
Their is a circuit in the Arduino that detects if an external power input has been connected and if so switches to that from USB power.

A schematic ( not a fritzing layout diagram ) would help us to see if the wiring contributed to the disaster, like did you have anything connected to the Vin pin?

Thanks for your reply! Nothing was connected to the Vin pin. I just picked up another Arduino and ran a multimeter on the AC-DC adapter, it gave me 12.35V. I think you're right that the circuit had something to do with it as it seems fine with just the Arduino and no devices plugged into it..

Should I try again plugging my servo motor, and mic with the 12V in, is this voltage safe? Or should I go back to using the USB and find a 9V supply or something?

We need to see a schematic of the wiring before we can answer that.

OK thats allright. With the new Arduino it connects to PC and the software recognises it.. It's not flashing at all when I'm uploading the code to it though and not showing anything in serial monitor, coming up with 'Error Uploading Code' sometimes and sometimes it seems to upload though doesn't flash or produce any output. What is going on with it??

What is going on with it??

Something is broken or you are not telling the IDE to choose the right serial port, or the right sort of Arduino.

I have tried it on several computers and tried changing the port number of the Arduino in the device manager though still getting Errors when trying to upload software. Could it be the USB cable damaged from the last device or a faulty new Arduino?

Could it be the USB cable damaged from the last device or a faulty new Arduino?

Yes it could, it could be anything.

OK I've got a new Arduino and a 9V alkaline battery now.. I'm trying to run the servo motor powered off the battery as we were having trouble running both the microphone and servo straight off the 5V Arduino supply, the microphone outputs in the serial monitor fluctuated quite a lot.

The way it is set up is I have a 22ohm resistor (9V / 22ohm = approx 400mA to give it close to what the USB max current output is) on the breadboard with the Positive of the battery connected to one side, the negative is going to a negative rail which shares with the Arduino ground.. The digital output of the servo is connected to a digital IO on the Arduino..

With this setup I can hear the servo vibrating and receiving power, yet it only turns 180 degrees one direction and doesn't turn back with any code that I have tried. I use the same code and power the servo via the 5V on the Arduino and the servo goes back and forth.

What is the problem here? :frowning:

Why are you using the resistor, it makes no sense. It looks like your servo needs more than 400mA to start up. When it is stopped it is in effect stalled. The stall current can typically be 1.5 A, so it needs that current to get it going. A 9V alkaline battery is not going to last much longer that five minutes, you probably already need a new one.

I read somewhere to use a current limiting resistor on the signal wire between the Arduino pin and the servo input.. Also we tried it without the resistor and our other servo motor (same type) smoked is now dead.

Also when you say it needs more than 400mA.. We were running it off the USB supply which is 500mA max and it was working off that?

I read somewhere to use a current limiting resistor on the signal wire between the Arduino pin and the servo input

That is crap.

You said:-

The way it is set up is I have a 22ohm resistor (9V / 22ohm = approx 400mA to give it close to what the USB max current output is)

That does not say you had a resistor in the signal line. Those words say the resistor in in seriese with the battery.

Also we tried it without the resistor and our other servo motor (same type) smoked is now dead.

So you did something else wrong.

We were running it off the USB supply which is 500mA max and it was working off that?

Probably because you were not testing it correctly. Functionality does not equal working fine.

http://forum.arduino.cc/index.php?topic=88094.0

If you mean the comment:-

  1. Use a current limiting resistor on the signal wire between the Arduino pin and the servo input

It is crap.

Anyway are you saying you can get anything approaching 400mA from a signal wire? You can't.