pico-examples icon indicating copy to clipboard operation
pico-examples copied to clipboard

Add tone generation example using PWM and piezo buzzer or a speaker

Open jcarranz97 opened this issue 2 years ago • 3 comments

NOTE - This PR depends on https://github.com/raspberrypi/pico-sdk/pull/1569 as it uses pico\tone.h library.

This example demonstrates how to use the tone library to generate tones using a piezo buzzer or a speaker.

The tone() function is similar to tone() from Arduino.

In this example, the Raspberry Pi Pico performs "Silent Night" melody to demonstrate how to reproduce tones that become melodies :notes: (I am using this to put some music on my Christmas Tree 🎄 🎅🏿 ).

Thanks!

jcarranz97 avatar Dec 03 '23 06:12 jcarranz97

What piezo are you using? The only one I had sounds terrible!

peterharperuk avatar Dec 21 '23 11:12 peterharperuk

What piezo are you using? The only one I had sounds terrible!

It is basically a passive buzzer (which does not make any sound when you directly give power). https://samueladesola.medium.com/how-to-play-the-musical-notes-on-the-arduino-1e9505d00c60#:~:text=Unlike%20the%20active%20buzzer%20that,%2C%20E%2C%20F%2C%20G.

image

jcarranz97 avatar Dec 23 '23 17:12 jcarranz97