41 different songs to play with a buzzer connected to a Raspberry Pi Pico.
buzzer.mp4
Download play.py, melodies.py and notes.py and save them to the Pico. Easiest way to do that is using the Thonny editor (here's a guide).
Then connect a buzzer to the Pico: one wire to pin 16 and the other to a ground pin, like so:
Once the buzzer is connected and the scripts are saved to the Pico, run play.py. You should hear the first tune!
In play.py you can change the volume and which track to play. Run the file again from Thonny when you change either.
Because all melodies are in one file, it's easy to add a button to switch to the next track. Connect one to a ground connection and pin 15, like so:
When you push the button, the Pico will play the next song on the list. It also prints the title of that song to the shell of your editor. If you don't have a button, then you can also make and break the connection with just a wire between those pins.
The buzzer (also called piezo speaker or piezo disk) comes in two flavors: active and passive. To play melodies you need the passive kind. The active buzzers are what make the 'beep' sound in electronic devices like hand scanners. They will try to produce the same frequency 'beep' no matter what tone you ask them to play.
You can also connect an amplified speaker to those pins, if you want more volume when you play the Super Mario theme :-)
- Star Trek intro
- Silent Night
- Pacman
- Ode an die Freude, Beethoven's Symphony No. 9
- Star Wars theme
- Wiegenlied (Brahms' Lullaby)
- Theme A from Tetris (Korobeiniki)
- Happy Birthday
- Darth Vader theme (Star Wars)
- Nokia Ringtone
- Mii Channel theme
- Minuet in G - Petzold
- Badinerie - Johann Sebastian Bach
- Für Elise - Ludwig van Beethoven
- Cantina Band (Star wars)
- Song of storms (The Legend of Zelda, Ocarina of Time)
- The Lion Sleeps Tonight
- The Lick
- Canon in D - Pachelbel
- At Doom's Gate
- Pink Panther theme
- Hedwig's theme (Harry Potter)
- Jigglypuff's Song (Pokémon)
- We Wish You a Merry Christmas
- Keyboard cat
- Game of Thrones
- Greensleeves
- Green Hill Zone (Sonic the Hedgehog)
- The Legend of Zelda theme
- Baby Elephant Walk
- Bloody Tears (Castlevania II)
- O Pulo da Gaita (Auto da Compadecida)
- Vampire Killer (Castlevania)
- Never Gonna Give You Up - Rick Astley
- Take on me - A-ha
- Prince Igor - Polovtsian Dances, Borodin
- Zelda's Lullaby - The Legend of Zelda, Ocarina of Time
- Super Mario Bros theme, by Koji Kondo
- Asa branca - Luiz Gonzaga
- The Godfather theme
- Professor Layton's theme
I run an electronics workshop at an art academy. I have decided to gradually switch over from the Arduino Uno to the Raspberry Pi Pico as the go-to board in my workshop. They're much faster and have more memory, are cheaper, and they run Python instead of C which is a better choice to start learning coding with. It's a nice bonus that the Pico can be programmed to act as a keyboard or mouse.
Connecting a buzzer to a microcontroller is a fun starter project. After making the first beeping sounds it's fun to also make it play songs. For Arduino there is this fine list of scripts to do that. To play those tunes with the Pico, it's easier to translate the scripts into the MicroPython language.
This adaptation also highlights one of the advantages of the Pico over the Arduino Uno. With the Arduino, each melody had to be a single file for it to fit on the Uno's limited flash memory of 32k bytes. That meant we had to upload a new file every time we wanted to try a different tune. The complete list of 41 melodies (together with the script to play melodies plus the notes frequencies, 125 Kb in total) easily fits on the 2 Megabyte memory of the Pico.
This is a port of Robson Couto's list of songs for Arduino: https://github.com/robsoncouto/arduino-songs The sources he used are mentioned in melodies.py. The script I used to scrape the melodies from the .ino files is in the archive folder. The sounds are all monophonic. If you want more complicated tunes, try out this repository.