Tone detector as input for servos

Hi,
I'm not very familiar with arduino, but i would really like to work on some projects I have thought of.

I want to make a tone detector that directly sends an input to a servo when the frequency that is assigned to it is heard by the sound module. So for example, i have 3 servos. I want one to be assigned to 150hz, the second to 170hz and the other to 200hz, so when the sensor detects those frequencies the servos change position; if it is a single beep the motor does a fast movement, if it is a large beep it maintains the "open" position and closes back.
So this is what i want to make. I don't know if it is hard to do or not, but I saw many projects on this forum and i hope it is simple.

So if there is any person who can help me a little I would be very grateful. I can't find specific tutorials for what I want to do.

What is the source of the tones, and how do you plan to detect them?

If using a microphone, you will need an amplifier and a good low pass audio filter to reduce spurious responses. The Goertzel and FFT or FHT methods can be used on Arduino to detect tones.

Ok so, i was planning to use a tone generator or some kind of music recording program to emulate different frequencies, and using the classic arduino sound module that has a microphone to detect that.
Actually, it would be much easier for me to just connect an audio jack/audio cable coming from a pc to arduino, but in that case, I don't know if is it possible to detect the frequencies coming from the cable. Like I said, i don't know much about arduino so I don't know those methods to detect tones. Because of this I'm asking an advice on how could I do this

Without knowing the particular audio example, it is impossible to predict how well an Arduino would work to detect specific tones.

Run a spectrum analyzer on your PC with the selected audio to see what I mean. On the display, can you easily identify the pitch of the sounds you hear? If so, the Arduino should also be able to do so.

Here is a free spectrum analyzer that I use on a Windows PC: https://www.qsl.net/dl4yhf/spectra1.html

Tanks for the help, but the thing is I don't have actually an audio sample right now. The frequency accurancy with the sensor would be a future issue that i would manage to do later, when I will make the samples, so I can do it trying different types of tones and see what's the best for arduino.
The thing I don't know how to do is the programming part where arduino tells to the motors to act when a frequency is detected. I hope to explain myself well

While there is a number of ways to decode a tone the very old LM567 Tone Decoder comes to mind. Along the lines of a DTMF (Dual Tone Multi Frequency) as used in today's telephone systems.

The LM567 and LM567C are general purpose tone decoders designed to provide a saturated transistor switch to ground when an input signal is present within the passband. The circuit consists of an I and Q detector driven by a voltage controlled oscillator which determines the center frequency of the decoder. External components are used to independently set center frequency, bandwidth and output delay.

Here is the data sheet.

DTMF Tone Generator modules are available online through Amazon and assorted retailers. Matter of fact you can likely find both the decoder and generator for less than you could build one. Run the decoder outputs like a latching low to your uC (Arduino or similar)

Using a PC to generate tones you could just use a software program like Audacity which can be had here at no cost.

Yes, you can also just use any of several Arduino flavors to capture and respond to an audio frequency signal. Start here.

Ron

That is the easy part. Figure out how to reliably detect tones first. One place to start is here: ArduinoFFT - Open Music Labs Wiki

2 Likes

IMO, you are painting a disaster for any 8-bit Arduino. With 32-bit, high clock frequency uC you may be able to pull it off.
Primary concern is you need the FFT to "bin" and separate frequencies very close together and you wish to differentiate tone duration at the same time; not something low-end FFT is designed to do well.

Think of those little guitar tuning instruments, you are ontune when the LED lights; now design a unit to simultaneously illuminate 3 separate LEDs... lots more effort... then expand to bracket LED ontime duration.

The solution is to do the frequency discrimination external to the Arduino into three (3) signals presented on 3 digital pins and allow the arduino to "time" the pins ontime and implement the signal duration logic. Microcontrollers deal with timing events to microseconds very readily and efficient state-machine logic is easy to implement.

Now the downside of your inquiry, even with forum assistance, this is a complex project and has all the earmarks of being very frustrating. Definitely not a newbie programmer project and doubly-so without a significant electronic background.

https://create.arduino.cc/projecthub/royba1999/goertzel-algorithm-41c3c8

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.