0
\$\begingroup\$

I am developing a product using the BLE NANO (nrf51822). Here is a pin out diagram: enter image description here
I was following some tutorials and they said to use PWM out of an analog pin to make sounds with a buzzer (I was debating on using po_29 for this). Currently I am using a digital pin out for an LED though (po_28) and I thought I'd try hooking the buzzer up to that. When I did the buzzer made noises just as expected. So my question is: is there a reason to use an analog pin / PWM for a buzzer or is it the same as just using a digital pin?

\$\endgroup\$
  • \$\begingroup\$ Please, tell us what is the device to where you connected your buzzer? Maybe some common microcomputer? Port name, number, pin number or a schematic diagram is welcome to avoid downvotes and to get other answers than nasty comments. Edit your question, do not add a comment! \$\endgroup\$ – user287001 Feb 7 '17 at 16:13
  • \$\begingroup\$ Alright I updated the question, is there any more info I should include? \$\endgroup\$ – Tyler Hilbert Feb 7 '17 at 16:19
0
\$\begingroup\$

If the buzzer is DC type applying the DC voltage will make it sound, some or speaker type which need a audible range frequency, so using PWM you can generate this tone

\$\endgroup\$
  • \$\begingroup\$ So to clarify, I can use PWM off a digital pin to adjust the tone? Is there a rule for how it will affect the tone (like increasing the duty cycle will increase the pitch?) \$\endgroup\$ – Tyler Hilbert Feb 8 '17 at 2:22
  • \$\begingroup\$ yes, if you buzzer is pizeo speaker you need to use pulse wave in the range of 20 - 20KHz, pitch corresponds to frequency, PWM operates in single frequency with varying duty cycle, by which you might get different musical tone \$\endgroup\$ – Raj Feb 8 '17 at 3:10
0
\$\begingroup\$

All PWM outputs of microcontrollers that I have seen have been digital. What would a analog PWM output even mean? Maybe allow you to set the high and low voltage levels? I have not heard of such a thing being integrated into a microcontroller PWM output, probably because there wouldn't be much use for it.

Your question is therefore based on a false premise, and can't be answered directly. To drive a speaker to make a fixed tone, the PWM output of a micro can be appropriate. These are always digital. The circuit then takes this digital signal and uses it to apply and not apply voltage to the speaker, or in some cases flip between two voltages.

\$\endgroup\$
  • \$\begingroup\$ Alright thanks for clarifying that the PWM would be digital. So to clarify, I can use any of the digital pins to PWM to the buzzer and change the tone? \$\endgroup\$ – Tyler Hilbert Feb 8 '17 at 2:24
0
\$\begingroup\$

Dont fix it if it's not broken. A DC buzzer needs only continuous DC. Silence the buzzer by turning that DC off.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.