Go Down

Topic: Can I control buzzer's tone AND volume at the same time? (Read 425 times) previous topic - next topic


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.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131