Astronomia (Coffin Meme) Tune on Arduino
Addicted to the viral Coffin Meme tune? Want to play it on an Arduino and use it in your projects? Here's how.
You only need two components: an Arduino and a Buzzer (and some jumper wires).
Code can be downloaded from https://github.com/pranavmittal611/AstronomiaArduino.
Includes “pitches.h” in the code (download from GitHub link above and place in the same folder as the .ino file), which contains frequencies of various musical notes which we will need to play the tune. Sets buzzer pin to 8, and button pin to 5.
Looptune is the number of times you want the tune to repeat after pressing the button. It can only be a positive integer.
Imports the frequencies of the notes we will be needing from “pitches.h” and stores them in an array named melody.
Configures the button pin to receive input by pulling it high. Multiplies looptune by 72, which is the number of musical notes in the melody array.
Checks if button is pressed. If yes, plays tune twice (looptune number of times) using the tone function.