Shows how to use the System.Device.Pwm API to use Pulse Width Modulation pins.
We will use the embedded LED present on the board for this case. You can also use an external LED with the 100-ohm resistor. You can follow the following schema.
And if you want to know more about PWM, how this works, you can read the All what you've always wanted to know about PWM content!
We will use the pin 25 for this example. Just connect your buzzer on the ground on one pin and the pin 25. You can adjust the pin if you want, you'll have to adjust the code as well:
Ensure you have all the software requirements.
To build the sample, follow the section here. And to run it, here.
The sample is located here. The code is using PWM to generate the frequencies for the soung. This is typically how the sound was produced in the early 80's on PC!
This sample uses the Buzzer nuget and the detailed explanations are available here.
And as a result, you will hear like in this video!
If you want to debug, follow the instructions explained in the led sample.