Can I control buzzer's tone AND volume at the same time?

Hi, Will appreciate your help with this question:

I want to build a Theremin using a buzzer and 2 proximity sensors, where one sensor controls the volume and the other one controls the tone (of the same buzzer). For the volume I thought I'll use the commend analogWrite(Pin, Sensor1), and for the tone I'll use the command tone(Pin, Sensor2)

But is that feasible? The buzzer is connected by a single analog pin to the board, so I'm not sure how I can give it 2 different inputs.

Any thoughts/suggestions? Is that even possible?

Will appreciate your help. Thanks in advance!

The short answer is no… The Arduino doesn’t have a true digital-to-analog converter… It can’t put-out sine waves and there is no volume control.

You can control the volume of a rectangle wave by changing the duty cycle. A 50% duty-cycle (square wave) will have maximum volume. But, changing the duty-cycle changes the character of the tone (without actually the fundamental frequency or “note”).

I believe a regular Theremin puts-out sine waves (or near sine waves), close to “pure tones”. A square or rectangular wave is very synthesizer-sounding.

Also, you won’t get much range from a piezo transducer. These are useful as tweeters (high-frequencies), but for example you wouldn’t want to listen to the radio or TV with only a piezo.

And, you want a speaker/transducer, not a “buzzer” which has it’s own sound-generator built-in.

If you want to use a normal speaker, you’ll need a little amplifier. You can’t drive an 8-Ohm speaker directly with the Arduino. Or, you can use “computer speakers” where are active/powered with a built-in amplifier.

The buzzer is connected by a single analog pin to the board, so I’m not sure how I can give it 2 different inputs.

I think you are confusing inputs and outputs. You could have one input controlling pitch and another input controlling volume, with output and one speaker. But, you need an audio shield with a true analog-output.

Thanks DVDdoug, I appreciate the quick response.

I think that I wasn't very clear when I used the term input. My buzzer is connected to GND and to one analog sensor. I'm not sure how this single analog sensor can be used to control both the sound and the tone at the same time, using different values for each (hope my question makes more sense now).

Anyway using computer speakers, as you suggested, will probably solve both of my problems.

Thanks again!

The answer is still no. The analog sensor returns a varying DC signal and your buzzer needs an AC signal.

Hi Avital,

same question for me (I am rookie)

after reading all reply I know the short answer is no, but....

but I have an idea..

I can control the volume by adding a variable resistor and adjust by finger

what if I adding a servo motor to adjust its resistance?

maybe we can try this~

good luck!

Please start your own thread, this one is three years old. As the OP is now shown as a guest, this means he is no longer a member of this forum and so won’t get your message.

Also give more detail about what sort of buzzer you have when you start your own thread.

DVDdoug: The short answer is no... The Arduino doesn't have a true digital-to-analog converter... It can't put-out sine waves and there is no volume control.

However that's not a problem as you can use ultrasonic PWM and modulate any waveform onto it, and the human ear can't tell the difference from a true sinewave. With noise shaping you can approach 16bit audio quality or better from a single 8 bit PWM pin. See post #5 on this thread: