├── hardware.png ├── thelick └── thelick.ino ├── startrekintro └── startrekintro.ino ├── nokia └── nokia.ino ├── README.md ├── pacman └── pacman.ino ├── happybirthday └── happybirthday.ino ├── jigglypuffsong └── jigglypuffsong.ino ├── brahmslullaby └── brahmslullaby.ino ├── zeldaslullaby └── zeldaslullaby.ino ├── silentnight └── silentnight.ino ├── keyboardcat └── keyboardcat.ino ├── babyelephantwalk └── babyelephantwalk.ino ├── odetojoy └── odetojoy.ino ├── cantinaband └── cantinaband.ino ├── songofstorms └── songofstorms.ino ├── starwars └── starwars.ino ├── harrypotter └── harrypotter.ino ├── asabranca └── asabranca.ino ├── takeonme └── takeonme.ino ├── pinkpanther └── pinkpanther.ino ├── imperialmarch └── imperialmarch.ino ├── tetris └── tetris.ino ├── zeldatheme └── zeldatheme.ino ├── cannonind └── cannonind.ino ├── thegodfather └── thegodfather.ino ├── gameofthrones └── gameofthrones.ino ├── greensleeves └── greensleeves.ino ├── princeigor └── princeigor.ino ├── greenhill └── greenhill.ino ├── minuetg └── minuetg.ino ├── merrychristmas └── merrychristmas.ino ├── pulodagaita └── pulodagaita.ino ├── vampirekiller └── vampirekiller.ino ├── thebadinerie └── badinerie.ino ├── miichannel └── miichannel.ino └── supermariobros └── supermariobros.ino /hardware.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robsoncouto/arduino-songs/HEAD/hardware.png -------------------------------------------------------------------------------- /thelick/thelick.ino: -------------------------------------------------------------------------------- 1 | /* 2 | The lick 3 | Connect a piezo buzzer or speaker to pin 11 or select a new pin. 4 | More songs available at https://github.com/robsoncouto/arduino-songs 5 | 6 | Robson Couto, 2019 7 | */ 8 | 9 | 10 | #define NOTE_B0 31 11 | #define NOTE_C1 33 12 | #define NOTE_CS1 35 13 | #define NOTE_D1 37 14 | #define NOTE_DS1 39 15 | #define NOTE_E1 41 16 | #define NOTE_F1 44 17 | #define NOTE_FS1 46 18 | #define NOTE_G1 49 19 | #define NOTE_GS1 52 20 | #define NOTE_A1 55 21 | #define NOTE_AS1 58 22 | #define NOTE_B1 62 23 | #define NOTE_C2 65 24 | #define NOTE_CS2 69 25 | #define NOTE_D2 73 26 | #define NOTE_DS2 78 27 | #define NOTE_E2 82 28 | #define NOTE_F2 87 29 | #define NOTE_FS2 93 30 | #define NOTE_G2 98 31 | #define NOTE_GS2 104 32 | #define NOTE_A2 110 33 | #define NOTE_AS2 117 34 | #define NOTE_B2 123 35 | #define NOTE_C3 131 36 | #define NOTE_CS3 139 37 | #define NOTE_D3 147 38 | #define NOTE_DS3 156 39 | #define NOTE_E3 165 40 | #define NOTE_F3 175 41 | #define NOTE_FS3 185 42 | #define NOTE_G3 196 43 | #define NOTE_GS3 208 44 | #define NOTE_A3 220 45 | #define NOTE_AS3 233 46 | #define NOTE_B3 247 47 | #define NOTE_C4 262 48 | #define NOTE_CS4 277 49 | #define NOTE_D4 294 50 | #define NOTE_DS4 311 51 | #define NOTE_E4 330 52 | #define NOTE_F4 349 53 | #define NOTE_FS4 370 54 | #define NOTE_G4 392 55 | #define NOTE_GS4 415 56 | #define NOTE_A4 440 57 | #define NOTE_AS4 466 58 | #define NOTE_B4 494 59 | #define NOTE_C5 523 60 | #define NOTE_CS5 554 61 | #define NOTE_D5 587 62 | #define NOTE_DS5 622 63 | #define NOTE_E5 659 64 | #define NOTE_F5 698 65 | #define NOTE_FS5 740 66 | #define NOTE_G5 784 67 | #define NOTE_GS5 831 68 | #define NOTE_A5 880 69 | #define NOTE_AS5 932 70 | #define NOTE_B5 988 71 | #define NOTE_C6 1047 72 | #define NOTE_CS6 1109 73 | #define NOTE_D6 1175 74 | #define NOTE_DS6 1245 75 | #define NOTE_E6 1319 76 | #define NOTE_F6 1397 77 | #define NOTE_FS6 1480 78 | #define NOTE_G6 1568 79 | #define NOTE_GS6 1661 80 | #define NOTE_A6 1760 81 | #define NOTE_AS6 1865 82 | #define NOTE_B6 1976 83 | #define NOTE_C7 2093 84 | #define NOTE_CS7 2217 85 | #define NOTE_D7 2349 86 | #define NOTE_DS7 2489 87 | #define NOTE_E7 2637 88 | #define NOTE_F7 2794 89 | #define NOTE_FS7 2960 90 | #define NOTE_G7 3136 91 | #define NOTE_GS7 3322 92 | #define NOTE_A7 3520 93 | #define NOTE_AS7 3729 94 | #define NOTE_B7 3951 95 | #define NOTE_C8 4186 96 | #define NOTE_CS8 4435 97 | #define NOTE_D8 4699 98 | #define NOTE_DS8 4978 99 | #define REST 0 100 | 101 | 102 | // change this to make the song slower or faster 103 | int tempo = 108; 104 | 105 | // change this to whichever pin you want to use 106 | int buzzer = 11; 107 | 108 | // notes of the moledy followed by the duration. 109 | // a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on 110 | // !!negative numbers are used to represent dotted notes, 111 | // so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!! 112 | int melody[] = { 113 | 114 | // The Lick 115 | NOTE_D4,8, NOTE_E4,8, NOTE_F4,8, NOTE_G4,8, NOTE_E4,4, NOTE_C4,8, NOTE_D4,1, 116 | 117 | }; 118 | 119 | // sizeof gives the number of bytes, each int value is composed of two bytes (16 bits) 120 | // there are two values per note (pitch and duration), so for each note there are four bytes 121 | int notes = sizeof(melody) / sizeof(melody[0]) / 2; 122 | 123 | // this calculates the duration of a whole note in ms 124 | int wholenote = (60000 * 4) / tempo; 125 | 126 | int divider = 0, noteDuration = 0; 127 | 128 | void setup() { 129 | // iterate over the notes of the melody. 130 | // Remember, the array is twice the number of notes (notes + durations) 131 | for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) { 132 | 133 | // calculates the duration of each note 134 | divider = melody[thisNote + 1]; 135 | if (divider > 0) { 136 | // regular note, just proceed 137 | noteDuration = (wholenote) / divider; 138 | } else if (divider < 0) { 139 | // dotted notes are represented with negative durations!! 140 | noteDuration = (wholenote) / abs(divider); 141 | noteDuration *= 1.5; // increases the duration in half for dotted notes 142 | } 143 | 144 | // we only play the note for 90% of the duration, leaving 10% as a pause 145 | tone(buzzer, melody[thisNote], noteDuration*0.9); 146 | 147 | // Wait for the specief duration before playing the next note. 148 | delay(noteDuration); 149 | 150 | // stop the waveform generation before the next note. 151 | noTone(buzzer); 152 | } 153 | } 154 | 155 | void loop() { 156 | // no need to repeat the melody. 157 | } 158 | -------------------------------------------------------------------------------- /startrekintro/startrekintro.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Start trek Intro 3 | Connect a piezo buzzer or speaker to pin 11 or select a new pin. 4 | More songs available at https://github.com/robsoncouto/arduino-songs 5 | 6 | Robson Couto, 2019 7 | */ 8 | #define NOTE_B0 31 9 | #define NOTE_C1 33 10 | #define NOTE_CS1 35 11 | #define NOTE_D1 37 12 | #define NOTE_DS1 39 13 | #define NOTE_E1 41 14 | #define NOTE_F1 44 15 | #define NOTE_FS1 46 16 | #define NOTE_G1 49 17 | #define NOTE_GS1 52 18 | #define NOTE_A1 55 19 | #define NOTE_AS1 58 20 | #define NOTE_B1 62 21 | #define NOTE_C2 65 22 | #define NOTE_CS2 69 23 | #define NOTE_D2 73 24 | #define NOTE_DS2 78 25 | #define NOTE_E2 82 26 | #define NOTE_F2 87 27 | #define NOTE_FS2 93 28 | #define NOTE_G2 98 29 | #define NOTE_GS2 104 30 | #define NOTE_A2 110 31 | #define NOTE_AS2 117 32 | #define NOTE_B2 123 33 | #define NOTE_C3 131 34 | #define NOTE_CS3 139 35 | #define NOTE_D3 147 36 | #define NOTE_DS3 156 37 | #define NOTE_E3 165 38 | #define NOTE_F3 175 39 | #define NOTE_FS3 185 40 | #define NOTE_G3 196 41 | #define NOTE_GS3 208 42 | #define NOTE_A3 220 43 | #define NOTE_AS3 233 44 | #define NOTE_B3 247 45 | #define NOTE_C4 262 46 | #define NOTE_CS4 277 47 | #define NOTE_D4 294 48 | #define NOTE_DS4 311 49 | #define NOTE_E4 330 50 | #define NOTE_F4 349 51 | #define NOTE_FS4 370 52 | #define NOTE_G4 392 53 | #define NOTE_GS4 415 54 | #define NOTE_A4 440 55 | #define NOTE_AS4 466 56 | #define NOTE_B4 494 57 | #define NOTE_C5 523 58 | #define NOTE_CS5 554 59 | #define NOTE_D5 587 60 | #define NOTE_DS5 622 61 | #define NOTE_E5 659 62 | #define NOTE_F5 698 63 | #define NOTE_FS5 740 64 | #define NOTE_G5 784 65 | #define NOTE_GS5 831 66 | #define NOTE_A5 880 67 | #define NOTE_AS5 932 68 | #define NOTE_B5 988 69 | #define NOTE_C6 1047 70 | #define NOTE_CS6 1109 71 | #define NOTE_D6 1175 72 | #define NOTE_DS6 1245 73 | #define NOTE_E6 1319 74 | #define NOTE_F6 1397 75 | #define NOTE_FS6 1480 76 | #define NOTE_G6 1568 77 | #define NOTE_GS6 1661 78 | #define NOTE_A6 1760 79 | #define NOTE_AS6 1865 80 | #define NOTE_B6 1976 81 | #define NOTE_C7 2093 82 | #define NOTE_CS7 2217 83 | #define NOTE_D7 2349 84 | #define NOTE_DS7 2489 85 | #define NOTE_E7 2637 86 | #define NOTE_F7 2794 87 | #define NOTE_FS7 2960 88 | #define NOTE_G7 3136 89 | #define NOTE_GS7 3322 90 | #define NOTE_A7 3520 91 | #define NOTE_AS7 3729 92 | #define NOTE_B7 3951 93 | #define NOTE_C8 4186 94 | #define NOTE_CS8 4435 95 | #define NOTE_D8 4699 96 | #define NOTE_DS8 4978 97 | #define REST 0 98 | 99 | 100 | // change this to make the song slower or faster 101 | int tempo = 80; 102 | 103 | // change this to whichever pin you want to use 104 | int buzzer = 11; 105 | 106 | // notes of the moledy followed by the duration. 107 | // a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on 108 | // !!negative numbers are used to represent dotted notes, 109 | // so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!! 110 | int melody[] = { 111 | 112 | // Star Trek Intro 113 | // Score available at https://musescore.com/user/10768291/scores/4594271 114 | 115 | NOTE_D4, -8, NOTE_G4, 16, NOTE_C5, -4, 116 | NOTE_B4, 8, NOTE_G4, -16, NOTE_E4, -16, NOTE_A4, -16, 117 | NOTE_D5, 2, 118 | 119 | }; 120 | 121 | // sizeof gives the number of bytes, each int value is composed of two bytes (16 bits) 122 | // there are two values per note (pitch and duration), so for each note there are four bytes 123 | int notes = sizeof(melody) / sizeof(melody[0]) / 2; 124 | 125 | // this calculates the duration of a whole note in ms 126 | int wholenote = (60000 * 4) / tempo; 127 | 128 | int divider = 0, noteDuration = 0; 129 | 130 | void setup() { 131 | // iterate over the notes of the melody. 132 | // Remember, the array is twice the number of notes (notes + durations) 133 | for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) { 134 | 135 | // calculates the duration of each note 136 | divider = melody[thisNote + 1]; 137 | if (divider > 0) { 138 | // regular note, just proceed 139 | noteDuration = (wholenote) / divider; 140 | } else if (divider < 0) { 141 | // dotted notes are represented with negative durations!! 142 | noteDuration = (wholenote) / abs(divider); 143 | noteDuration *= 1.5; // increases the duration in half for dotted notes 144 | } 145 | 146 | // we only play the note for 90% of the duration, leaving 10% as a pause 147 | tone(buzzer, melody[thisNote], noteDuration * 0.9); 148 | 149 | // Wait for the specief duration before playing the next note. 150 | delay(noteDuration); 151 | 152 | // stop the waveform generation before the next note. 153 | noTone(buzzer); 154 | } 155 | } 156 | 157 | void loop() { 158 | // no need to repeat the melody. 159 | } 160 | -------------------------------------------------------------------------------- /nokia/nokia.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Nokia Tune 3 | Connect a piezo buzzer or speaker to pin 11 or select a new pin. 4 | More songs available at https://github.com/robsoncouto/arduino-songs 5 | 6 | Robson Couto, 2019 7 | */ 8 | #define NOTE_B0 31 9 | #define NOTE_C1 33 10 | #define NOTE_CS1 35 11 | #define NOTE_D1 37 12 | #define NOTE_DS1 39 13 | #define NOTE_E1 41 14 | #define NOTE_F1 44 15 | #define NOTE_FS1 46 16 | #define NOTE_G1 49 17 | #define NOTE_GS1 52 18 | #define NOTE_A1 55 19 | #define NOTE_AS1 58 20 | #define NOTE_B1 62 21 | #define NOTE_C2 65 22 | #define NOTE_CS2 69 23 | #define NOTE_D2 73 24 | #define NOTE_DS2 78 25 | #define NOTE_E2 82 26 | #define NOTE_F2 87 27 | #define NOTE_FS2 93 28 | #define NOTE_G2 98 29 | #define NOTE_GS2 104 30 | #define NOTE_A2 110 31 | #define NOTE_AS2 117 32 | #define NOTE_B2 123 33 | #define NOTE_C3 131 34 | #define NOTE_CS3 139 35 | #define NOTE_D3 147 36 | #define NOTE_DS3 156 37 | #define NOTE_E3 165 38 | #define NOTE_F3 175 39 | #define NOTE_FS3 185 40 | #define NOTE_G3 196 41 | #define NOTE_GS3 208 42 | #define NOTE_A3 220 43 | #define NOTE_AS3 233 44 | #define NOTE_B3 247 45 | #define NOTE_C4 262 46 | #define NOTE_CS4 277 47 | #define NOTE_D4 294 48 | #define NOTE_DS4 311 49 | #define NOTE_E4 330 50 | #define NOTE_F4 349 51 | #define NOTE_FS4 370 52 | #define NOTE_G4 392 53 | #define NOTE_GS4 415 54 | #define NOTE_A4 440 55 | #define NOTE_AS4 466 56 | #define NOTE_B4 494 57 | #define NOTE_C5 523 58 | #define NOTE_CS5 554 59 | #define NOTE_D5 587 60 | #define NOTE_DS5 622 61 | #define NOTE_E5 659 62 | #define NOTE_F5 698 63 | #define NOTE_FS5 740 64 | #define NOTE_G5 784 65 | #define NOTE_GS5 831 66 | #define NOTE_A5 880 67 | #define NOTE_AS5 932 68 | #define NOTE_B5 988 69 | #define NOTE_C6 1047 70 | #define NOTE_CS6 1109 71 | #define NOTE_D6 1175 72 | #define NOTE_DS6 1245 73 | #define NOTE_E6 1319 74 | #define NOTE_F6 1397 75 | #define NOTE_FS6 1480 76 | #define NOTE_G6 1568 77 | #define NOTE_GS6 1661 78 | #define NOTE_A6 1760 79 | #define NOTE_AS6 1865 80 | #define NOTE_B6 1976 81 | #define NOTE_C7 2093 82 | #define NOTE_CS7 2217 83 | #define NOTE_D7 2349 84 | #define NOTE_DS7 2489 85 | #define NOTE_E7 2637 86 | #define NOTE_F7 2794 87 | #define NOTE_FS7 2960 88 | #define NOTE_G7 3136 89 | #define NOTE_GS7 3322 90 | #define NOTE_A7 3520 91 | #define NOTE_AS7 3729 92 | #define NOTE_B7 3951 93 | #define NOTE_C8 4186 94 | #define NOTE_CS8 4435 95 | #define NOTE_D8 4699 96 | #define NOTE_DS8 4978 97 | #define REST 0 98 | 99 | 100 | // change this to make the song slower or faster 101 | int tempo = 180; 102 | 103 | // change this to whichever pin you want to use 104 | int buzzer = 11; 105 | 106 | // notes of the moledy followed by the duration. 107 | // a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on 108 | // !!negative numbers are used to represent dotted notes, 109 | // so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!! 110 | int melody[] = { 111 | 112 | // Nokia Ringtone 113 | // Score available at https://musescore.com/user/29944637/scores/5266155 114 | 115 | NOTE_E5, 8, NOTE_D5, 8, NOTE_FS4, 4, NOTE_GS4, 4, 116 | NOTE_CS5, 8, NOTE_B4, 8, NOTE_D4, 4, NOTE_E4, 4, 117 | NOTE_B4, 8, NOTE_A4, 8, NOTE_CS4, 4, NOTE_E4, 4, 118 | NOTE_A4, 2, 119 | }; 120 | 121 | // sizeof gives the number of bytes, each int value is composed of two bytes (16 bits) 122 | // there are two values per note (pitch and duration), so for each note there are four bytes 123 | int notes = sizeof(melody) / sizeof(melody[0]) / 2; 124 | 125 | // this calculates the duration of a whole note in ms 126 | int wholenote = (60000 * 4) / tempo; 127 | 128 | int divider = 0, noteDuration = 0; 129 | 130 | void setup() { 131 | // iterate over the notes of the melody. 132 | // Remember, the array is twice the number of notes (notes + durations) 133 | for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) { 134 | 135 | // calculates the duration of each note 136 | divider = melody[thisNote + 1]; 137 | if (divider > 0) { 138 | // regular note, just proceed 139 | noteDuration = (wholenote) / divider; 140 | } else if (divider < 0) { 141 | // dotted notes are represented with negative durations!! 142 | noteDuration = (wholenote) / abs(divider); 143 | noteDuration *= 1.5; // increases the duration in half for dotted notes 144 | } 145 | 146 | // we only play the note for 90% of the duration, leaving 10% as a pause 147 | tone(buzzer, melody[thisNote], noteDuration * 0.9); 148 | 149 | // Wait for the specief duration before playing the next note. 150 | delay(noteDuration); 151 | 152 | // stop the waveform generation before the next note. 153 | noTone(buzzer); 154 | } 155 | } 156 | 157 | void loop() { 158 | // no need to repeat the melody. 159 | } 160 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Songs for playing on Arduino boards. 2 | 3 | ## Usage 4 | 5 | Every code here should run on every arduino board without problems. The sketches rely solely on the tone() function from Arduino, so the sounds are all monophonic. On the bright side, **libraries are not required**. 6 | 7 | If you want to compare the code with the original score, I try to group the notes in a measure as one line of ccode and the staves as groups of lines. However, in some cases notes will be tied together among measures or be dotted and this rule is broken. 8 | 9 | ## Hardware 10 | 11 | Just connect an piezo to the board and you are good to go. Pin 11 is used in every sketch because some piezo speakers can be connected between it and the close GND pin without any wiring. You can use basically any pin, as long as they can be used as digital pins (pins A6 and A7 of the Arduino Nano and mini are analog only). Just remember to assign the pin number to the `buzzer` variable. 12 | 13 | ![alt tag](hardware.png) 14 | 15 | There are two kinds of piezo buzzers: active and passive. The active one that plays a specific pitch when powevered and is not good for this purpose. The passive kind functions like a speaker, reproducing the pitch you apply to it. You can test the piezo speaker with the "blink" example, the good piezo speaker will just click, while the other kind will play a pitch every other second. 16 | 17 | ## List of tunes 18 | 19 | ### Movies 20 | 21 | * [Cantina Band from Star Wars](https://github.com/robsoncouto/arduino-songs/blob/master/cantinaband/cantinaband.ino) 22 | * [Imperial March from Star Wars](https://github.com/robsoncouto/arduino-songs/blob/master/imperialmarch/imperialmarch.ino) 23 | * [Hedwig's theme from Harry Potter](https://github.com/robsoncouto/arduino-songs/blob/master/harrypotter/harrypotter.ino) 24 | * [Star Wars theme](https://github.com/robsoncouto/arduino-songs/blob/master/starwars/starwars.ino) 25 | * [Pulo da gaita from the Brazilian Movie *O Auto da Compadecida*](https://github.com/robsoncouto/arduino-songs/blob/master/pulodagaita/pulodagaita.ino) 26 | 27 | ### Games 28 | 29 | * [Bloody Tears from Castlevania II](https://github.com/robsoncouto/arduino-songs/blob/master/bloodytears/bloodytears.ino) 30 | * [Green Hill Zone from *Sonic the Hedgehog*](https://github.com/robsoncouto/arduino-songs/blob/master/greenhill/greenhill.ino) 31 | * [Mii channel theme](https://github.com/robsoncouto/arduino-songs/blob/master/miichannel/miichannel.ino) 32 | * [Professor Layton's theme from *Professor Layton and the Curious Village*](https://github.com/robsoncouto/arduino-songs) 33 | * [Song of stomrs from *The Legend of Zelda Ocarina of time*](https://github.com/robsoncouto/arduino-songs/blob/master/songofstorms/songofstorms.ino) 34 | * [Super Mario Bros' overworld theme](https://github.com/robsoncouto/arduino-songs/blob/master/supermariobros/supermariobros.ino) 35 | * [Tetris theme (Korobeiniki)](https://github.com/robsoncouto/arduino-songs/blob/master/tetris/tetris.ino) 36 | * [Zelda's Lullaby from *The Legend of Zelda Ocarina of time*](https://github.com/robsoncouto/arduino-songs/blob/master/zeldaslullaby/zeldaslullaby.ino) 37 | * [The Legend of Zelda for the NES](https://github.com/robsoncouto/arduino-songs/blob/master/zeldatheme/zeldatheme.ino) 38 | * [Pacman](https://github.com/robsoncouto/arduino-songs/blob/master/pacman/pacman.ino) 39 | 40 | ### Classic 41 | * [Cannon in D - Pachelbel](https://github.com/robsoncouto/arduino-songs/blob/master/cannonind/cannonind.ino) 42 | * [Greensleeves](https://github.com/robsoncouto/arduino-songs/blob/master/greensleeves/greensleeves.ino) 43 | * [Ode to Joy - Beethoven's Symphony No. 9](https://github.com/robsoncouto/arduino-songs/blob/master/odetojoy/odetojoy.ino) 44 | * [Prince Igor - Borodin's Polovtsian Dances](https://github.com/robsoncouto/arduino-songs/blob/master/princeigor/princeigor.ino) 45 | * [Minuet in G - Christian Petzold](https://github.com/robsoncouto/arduino-songs/blob/master/minuetg/minuetg.ino) 46 | 47 | ### Others 48 | 49 | * [Asa Branca - Luiz Gonzaga](https://github.com/robsoncouto/arduino-songs/blob/master/asabranca/asabranca.ino) 50 | * [Pink Panther Theme](https://github.com/robsoncouto/arduino-songs/blob/master/pinkpanther/pinkpanther.ino) 51 | * [Take on me A-ha](https://github.com/robsoncouto/arduino-songs/blob/master/takeonme/takeonme.ino) 52 | * [The lick](https://github.com/robsoncouto/arduino-songs/blob/master/thelick/thelick.ino) 53 | * [The Lion sleeps tonight (*A-weema-weh*)](https://github.com/robsoncouto/arduino-songs/blob/master/thelionsleepstonight/thelionsleepstonight.ino) 54 | * [Take on me](https://github.com/robsoncouto/arduino-songs/blob/master/takeonme/takeonme.ino) 55 | * [Keyboard cat](https://github.com/robsoncouto/arduino-songs/blob/master/keyboardcat/keyboardcat.ino) 56 | * [Nokia Ringtone](https://github.com/robsoncouto/arduino-songs/blob/master/nokia/nokia.ino) 57 | 58 | ## Copyright 59 | 60 | Every sketch here has been written by myself, although based on scores I found online or books I own. These scores are linked in each file when possible. You can use the sketches for anything, I only kindly ask that you give credit if you use these codes on a tutorial, video, example, etc. 61 | -------------------------------------------------------------------------------- /pacman/pacman.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Pacman Intro Theme 3 | Connect a piezo buzzer or speaker to pin 11 or select a new pin. 4 | More songs available at https://github.com/robsoncouto/arduino-songs 5 | 6 | Robson Couto, 2019 7 | */ 8 | #define NOTE_B0 31 9 | #define NOTE_C1 33 10 | #define NOTE_CS1 35 11 | #define NOTE_D1 37 12 | #define NOTE_DS1 39 13 | #define NOTE_E1 41 14 | #define NOTE_F1 44 15 | #define NOTE_FS1 46 16 | #define NOTE_G1 49 17 | #define NOTE_GS1 52 18 | #define NOTE_A1 55 19 | #define NOTE_AS1 58 20 | #define NOTE_B1 62 21 | #define NOTE_C2 65 22 | #define NOTE_CS2 69 23 | #define NOTE_D2 73 24 | #define NOTE_DS2 78 25 | #define NOTE_E2 82 26 | #define NOTE_F2 87 27 | #define NOTE_FS2 93 28 | #define NOTE_G2 98 29 | #define NOTE_GS2 104 30 | #define NOTE_A2 110 31 | #define NOTE_AS2 117 32 | #define NOTE_B2 123 33 | #define NOTE_C3 131 34 | #define NOTE_CS3 139 35 | #define NOTE_D3 147 36 | #define NOTE_DS3 156 37 | #define NOTE_E3 165 38 | #define NOTE_F3 175 39 | #define NOTE_FS3 185 40 | #define NOTE_G3 196 41 | #define NOTE_GS3 208 42 | #define NOTE_A3 220 43 | #define NOTE_AS3 233 44 | #define NOTE_B3 247 45 | #define NOTE_C4 262 46 | #define NOTE_CS4 277 47 | #define NOTE_D4 294 48 | #define NOTE_DS4 311 49 | #define NOTE_E4 330 50 | #define NOTE_F4 349 51 | #define NOTE_FS4 370 52 | #define NOTE_G4 392 53 | #define NOTE_GS4 415 54 | #define NOTE_A4 440 55 | #define NOTE_AS4 466 56 | #define NOTE_B4 494 57 | #define NOTE_C5 523 58 | #define NOTE_CS5 554 59 | #define NOTE_D5 587 60 | #define NOTE_DS5 622 61 | #define NOTE_E5 659 62 | #define NOTE_F5 698 63 | #define NOTE_FS5 740 64 | #define NOTE_G5 784 65 | #define NOTE_GS5 831 66 | #define NOTE_A5 880 67 | #define NOTE_AS5 932 68 | #define NOTE_B5 988 69 | #define NOTE_C6 1047 70 | #define NOTE_CS6 1109 71 | #define NOTE_D6 1175 72 | #define NOTE_DS6 1245 73 | #define NOTE_E6 1319 74 | #define NOTE_F6 1397 75 | #define NOTE_FS6 1480 76 | #define NOTE_G6 1568 77 | #define NOTE_GS6 1661 78 | #define NOTE_A6 1760 79 | #define NOTE_AS6 1865 80 | #define NOTE_B6 1976 81 | #define NOTE_C7 2093 82 | #define NOTE_CS7 2217 83 | #define NOTE_D7 2349 84 | #define NOTE_DS7 2489 85 | #define NOTE_E7 2637 86 | #define NOTE_F7 2794 87 | #define NOTE_FS7 2960 88 | #define NOTE_G7 3136 89 | #define NOTE_GS7 3322 90 | #define NOTE_A7 3520 91 | #define NOTE_AS7 3729 92 | #define NOTE_B7 3951 93 | #define NOTE_C8 4186 94 | #define NOTE_CS8 4435 95 | #define NOTE_D8 4699 96 | #define NOTE_DS8 4978 97 | #define REST 0 98 | 99 | 100 | // change this to make the song slower or faster 101 | int tempo = 105; 102 | 103 | // change this to whichever pin you want to use 104 | int buzzer = 11; 105 | 106 | // notes of the moledy followed by the duration. 107 | // a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on 108 | // !!negative numbers are used to represent dotted notes, 109 | // so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!! 110 | int melody[] = { 111 | 112 | // Pacman 113 | // Score available at https://musescore.com/user/85429/scores/107109 114 | NOTE_B4, 16, NOTE_B5, 16, NOTE_FS5, 16, NOTE_DS5, 16, //1 115 | NOTE_B5, 32, NOTE_FS5, -16, NOTE_DS5, 8, NOTE_C5, 16, 116 | NOTE_C6, 16, NOTE_G6, 16, NOTE_E6, 16, NOTE_C6, 32, NOTE_G6, -16, NOTE_E6, 8, 117 | 118 | NOTE_B4, 16, NOTE_B5, 16, NOTE_FS5, 16, NOTE_DS5, 16, NOTE_B5, 32, //2 119 | NOTE_FS5, -16, NOTE_DS5, 8, NOTE_DS5, 32, NOTE_E5, 32, NOTE_F5, 32, 120 | NOTE_F5, 32, NOTE_FS5, 32, NOTE_G5, 32, NOTE_G5, 32, NOTE_GS5, 32, NOTE_A5, 16, NOTE_B5, 8 121 | }; 122 | 123 | // sizeof gives the number of bytes, each int value is composed of two bytes (16 bits) 124 | // there are two values per note (pitch and duration), so for each note there are four bytes 125 | int notes = sizeof(melody) / sizeof(melody[0]) / 2; 126 | 127 | // this calculates the duration of a whole note in ms 128 | int wholenote = (60000 * 4) / tempo; 129 | 130 | int divider = 0, noteDuration = 0; 131 | 132 | void setup() { 133 | // iterate over the notes of the melody. 134 | // Remember, the array is twice the number of notes (notes + durations) 135 | for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) { 136 | 137 | // calculates the duration of each note 138 | divider = melody[thisNote + 1]; 139 | if (divider > 0) { 140 | // regular note, just proceed 141 | noteDuration = (wholenote) / divider; 142 | } else if (divider < 0) { 143 | // dotted notes are represented with negative durations!! 144 | noteDuration = (wholenote) / abs(divider); 145 | noteDuration *= 1.5; // increases the duration in half for dotted notes 146 | } 147 | 148 | // we only play the note for 90% of the duration, leaving 10% as a pause 149 | tone(buzzer, melody[thisNote], noteDuration * 0.9); 150 | 151 | // Wait for the specief duration before playing the next note. 152 | delay(noteDuration); 153 | 154 | // stop the waveform generation before the next note. 155 | noTone(buzzer); 156 | } 157 | } 158 | 159 | void loop() { 160 | // no need to repeat the melody. 161 | } 162 | -------------------------------------------------------------------------------- /happybirthday/happybirthday.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Happy Birthday 3 | Connect a piezo buzzer or speaker to pin 11 or select a new pin. 4 | More songs available at https://github.com/robsoncouto/arduino-songs 5 | 6 | Robson Couto, 2019 7 | */ 8 | #define NOTE_B0 31 9 | #define NOTE_C1 33 10 | #define NOTE_CS1 35 11 | #define NOTE_D1 37 12 | #define NOTE_DS1 39 13 | #define NOTE_E1 41 14 | #define NOTE_F1 44 15 | #define NOTE_FS1 46 16 | #define NOTE_G1 49 17 | #define NOTE_GS1 52 18 | #define NOTE_A1 55 19 | #define NOTE_AS1 58 20 | #define NOTE_B1 62 21 | #define NOTE_C2 65 22 | #define NOTE_CS2 69 23 | #define NOTE_D2 73 24 | #define NOTE_DS2 78 25 | #define NOTE_E2 82 26 | #define NOTE_F2 87 27 | #define NOTE_FS2 93 28 | #define NOTE_G2 98 29 | #define NOTE_GS2 104 30 | #define NOTE_A2 110 31 | #define NOTE_AS2 117 32 | #define NOTE_B2 123 33 | #define NOTE_C3 131 34 | #define NOTE_CS3 139 35 | #define NOTE_D3 147 36 | #define NOTE_DS3 156 37 | #define NOTE_E3 165 38 | #define NOTE_F3 175 39 | #define NOTE_FS3 185 40 | #define NOTE_G3 196 41 | #define NOTE_GS3 208 42 | #define NOTE_A3 220 43 | #define NOTE_AS3 233 44 | #define NOTE_B3 247 45 | #define NOTE_C4 262 46 | #define NOTE_CS4 277 47 | #define NOTE_D4 294 48 | #define NOTE_DS4 311 49 | #define NOTE_E4 330 50 | #define NOTE_F4 349 51 | #define NOTE_FS4 370 52 | #define NOTE_G4 392 53 | #define NOTE_GS4 415 54 | #define NOTE_A4 440 55 | #define NOTE_AS4 466 56 | #define NOTE_B4 494 57 | #define NOTE_C5 523 58 | #define NOTE_CS5 554 59 | #define NOTE_D5 587 60 | #define NOTE_DS5 622 61 | #define NOTE_E5 659 62 | #define NOTE_F5 698 63 | #define NOTE_FS5 740 64 | #define NOTE_G5 784 65 | #define NOTE_GS5 831 66 | #define NOTE_A5 880 67 | #define NOTE_AS5 932 68 | #define NOTE_B5 988 69 | #define NOTE_C6 1047 70 | #define NOTE_CS6 1109 71 | #define NOTE_D6 1175 72 | #define NOTE_DS6 1245 73 | #define NOTE_E6 1319 74 | #define NOTE_F6 1397 75 | #define NOTE_FS6 1480 76 | #define NOTE_G6 1568 77 | #define NOTE_GS6 1661 78 | #define NOTE_A6 1760 79 | #define NOTE_AS6 1865 80 | #define NOTE_B6 1976 81 | #define NOTE_C7 2093 82 | #define NOTE_CS7 2217 83 | #define NOTE_D7 2349 84 | #define NOTE_DS7 2489 85 | #define NOTE_E7 2637 86 | #define NOTE_F7 2794 87 | #define NOTE_FS7 2960 88 | #define NOTE_G7 3136 89 | #define NOTE_GS7 3322 90 | #define NOTE_A7 3520 91 | #define NOTE_AS7 3729 92 | #define NOTE_B7 3951 93 | #define NOTE_C8 4186 94 | #define NOTE_CS8 4435 95 | #define NOTE_D8 4699 96 | #define NOTE_DS8 4978 97 | #define REST 0 98 | 99 | 100 | // change this to make the song slower or faster 101 | int tempo = 140; 102 | 103 | // change this to whichever pin you want to use 104 | int buzzer = 11; 105 | 106 | // notes of the moledy followed by the duration. 107 | // a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on 108 | // !!negative numbers are used to represent dotted notes, 109 | // so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!! 110 | int melody[] = { 111 | 112 | // Happy Birthday 113 | // Score available at https://musescore.com/user/8221/scores/26906 114 | 115 | NOTE_C4,4, NOTE_C4,8, 116 | NOTE_D4,-4, NOTE_C4,-4, NOTE_F4,-4, 117 | NOTE_E4,-2, NOTE_C4,4, NOTE_C4,8, 118 | NOTE_D4,-4, NOTE_C4,-4, NOTE_G4,-4, 119 | NOTE_F4,-2, NOTE_C4,4, NOTE_C4,8, 120 | 121 | NOTE_C5,-4, NOTE_A4,-4, NOTE_F4,-4, 122 | NOTE_E4,-4, NOTE_D4,-4, NOTE_AS4,4, NOTE_AS4,8, 123 | NOTE_A4,-4, NOTE_F4,-4, NOTE_G4,-4, 124 | NOTE_F4,-2, 125 | 126 | }; 127 | 128 | // sizeof gives the number of bytes, each int value is composed of two bytes (16 bits) 129 | // there are two values per note (pitch and duration), so for each note there are four bytes 130 | int notes = sizeof(melody) / sizeof(melody[0]) / 2; 131 | 132 | // this calculates the duration of a whole note in ms 133 | int wholenote = (60000 * 4) / tempo; 134 | 135 | int divider = 0, noteDuration = 0; 136 | 137 | void setup() { 138 | // iterate over the notes of the melody. 139 | // Remember, the array is twice the number of notes (notes + durations) 140 | for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) { 141 | 142 | // calculates the duration of each note 143 | divider = melody[thisNote + 1]; 144 | if (divider > 0) { 145 | // regular note, just proceed 146 | noteDuration = (wholenote) / divider; 147 | } else if (divider < 0) { 148 | // dotted notes are represented with negative durations!! 149 | noteDuration = (wholenote) / abs(divider); 150 | noteDuration *= 1.5; // increases the duration in half for dotted notes 151 | } 152 | 153 | // we only play the note for 90% of the duration, leaving 10% as a pause 154 | tone(buzzer, melody[thisNote], noteDuration * 0.9); 155 | 156 | // Wait for the specief duration before playing the next note. 157 | delay(noteDuration); 158 | 159 | // stop the waveform generation before the next note. 160 | noTone(buzzer); 161 | } 162 | } 163 | 164 | void loop() { 165 | // no need to repeat the melody. 166 | } 167 | -------------------------------------------------------------------------------- /jigglypuffsong/jigglypuffsong.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Jigglypuff's Song 3 | Connect a piezo buzzer or speaker to pin 11 or select a new pin. 4 | More songs available at https://github.com/robsoncouto/arduino-songs 5 | 6 | Robson Couto, 2019 7 | */ 8 | #define NOTE_B0 31 9 | #define NOTE_C1 33 10 | #define NOTE_CS1 35 11 | #define NOTE_D1 37 12 | #define NOTE_DS1 39 13 | #define NOTE_E1 41 14 | #define NOTE_F1 44 15 | #define NOTE_FS1 46 16 | #define NOTE_G1 49 17 | #define NOTE_GS1 52 18 | #define NOTE_A1 55 19 | #define NOTE_AS1 58 20 | #define NOTE_B1 62 21 | #define NOTE_C2 65 22 | #define NOTE_CS2 69 23 | #define NOTE_D2 73 24 | #define NOTE_DS2 78 25 | #define NOTE_E2 82 26 | #define NOTE_F2 87 27 | #define NOTE_FS2 93 28 | #define NOTE_G2 98 29 | #define NOTE_GS2 104 30 | #define NOTE_A2 110 31 | #define NOTE_AS2 117 32 | #define NOTE_B2 123 33 | #define NOTE_C3 131 34 | #define NOTE_CS3 139 35 | #define NOTE_D3 147 36 | #define NOTE_DS3 156 37 | #define NOTE_E3 165 38 | #define NOTE_F3 175 39 | #define NOTE_FS3 185 40 | #define NOTE_G3 196 41 | #define NOTE_GS3 208 42 | #define NOTE_A3 220 43 | #define NOTE_AS3 233 44 | #define NOTE_B3 247 45 | #define NOTE_C4 262 46 | #define NOTE_CS4 277 47 | #define NOTE_D4 294 48 | #define NOTE_DS4 311 49 | #define NOTE_E4 330 50 | #define NOTE_F4 349 51 | #define NOTE_FS4 370 52 | #define NOTE_G4 392 53 | #define NOTE_GS4 415 54 | #define NOTE_A4 440 55 | #define NOTE_AS4 466 56 | #define NOTE_B4 494 57 | #define NOTE_C5 523 58 | #define NOTE_CS5 554 59 | #define NOTE_D5 587 60 | #define NOTE_DS5 622 61 | #define NOTE_E5 659 62 | #define NOTE_F5 698 63 | #define NOTE_FS5 740 64 | #define NOTE_G5 784 65 | #define NOTE_GS5 831 66 | #define NOTE_A5 880 67 | #define NOTE_AS5 932 68 | #define NOTE_B5 988 69 | #define NOTE_C6 1047 70 | #define NOTE_CS6 1109 71 | #define NOTE_D6 1175 72 | #define NOTE_DS6 1245 73 | #define NOTE_E6 1319 74 | #define NOTE_F6 1397 75 | #define NOTE_FS6 1480 76 | #define NOTE_G6 1568 77 | #define NOTE_GS6 1661 78 | #define NOTE_A6 1760 79 | #define NOTE_AS6 1865 80 | #define NOTE_B6 1976 81 | #define NOTE_C7 2093 82 | #define NOTE_CS7 2217 83 | #define NOTE_D7 2349 84 | #define NOTE_DS7 2489 85 | #define NOTE_E7 2637 86 | #define NOTE_F7 2794 87 | #define NOTE_FS7 2960 88 | #define NOTE_G7 3136 89 | #define NOTE_GS7 3322 90 | #define NOTE_A7 3520 91 | #define NOTE_AS7 3729 92 | #define NOTE_B7 3951 93 | #define NOTE_C8 4186 94 | #define NOTE_CS8 4435 95 | #define NOTE_D8 4699 96 | #define NOTE_DS8 4978 97 | #define REST 0 98 | 99 | 100 | // change this to make the song slower or faster 101 | int tempo = 85; 102 | 103 | // change this to whichever pin you want to use 104 | int buzzer = 11; 105 | 106 | // notes of the moledy followed by the duration. 107 | // a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on 108 | // !!negative numbers are used to represent dotted notes, 109 | // so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!! 110 | int melody[] = { 111 | 112 | // Jigglypuff's Song 113 | // Score available at https://musescore.com/user/28109683/scores/5044153 114 | 115 | NOTE_D5,-4, NOTE_A5,8, NOTE_FS5,8, NOTE_D5,8, 116 | NOTE_E5,-4, NOTE_FS5,8, NOTE_G5,4, 117 | NOTE_FS5,-4, NOTE_E5,8, NOTE_FS5,4, 118 | NOTE_D5,-2, 119 | NOTE_D5,-4, NOTE_A5,8, NOTE_FS5,8, NOTE_D5,8, 120 | NOTE_E5,-4, NOTE_FS5,8, NOTE_G5,4, 121 | NOTE_FS5,-1, 122 | NOTE_D5,-4, NOTE_A5,8, NOTE_FS5,8, NOTE_D5,8, 123 | NOTE_E5,-4, NOTE_FS5,8, NOTE_G5,4, 124 | 125 | NOTE_FS5,-4, NOTE_E5,8, NOTE_FS5,4, 126 | NOTE_D5,-2, 127 | NOTE_D5,-4, NOTE_A5,8, NOTE_FS5,8, NOTE_D5,8, 128 | NOTE_E5,-4, NOTE_FS5,8, NOTE_G5,4, 129 | NOTE_FS5,-1, 130 | 131 | }; 132 | 133 | // sizeof gives the number of bytes, each int value is composed of two bytes (16 bits) 134 | // there are two values per note (pitch and duration), so for each note there are four bytes 135 | int notes = sizeof(melody) / sizeof(melody[0]) / 2; 136 | 137 | // this calculates the duration of a whole note in ms 138 | int wholenote = (60000 * 4) / tempo; 139 | 140 | int divider = 0, noteDuration = 0; 141 | 142 | void setup() { 143 | // iterate over the notes of the melody. 144 | // Remember, the array is twice the number of notes (notes + durations) 145 | for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) { 146 | 147 | // calculates the duration of each note 148 | divider = melody[thisNote + 1]; 149 | if (divider > 0) { 150 | // regular note, just proceed 151 | noteDuration = (wholenote) / divider; 152 | } else if (divider < 0) { 153 | // dotted notes are represented with negative durations!! 154 | noteDuration = (wholenote) / abs(divider); 155 | noteDuration *= 1.5; // increases the duration in half for dotted notes 156 | } 157 | 158 | // we only play the note for 90% of the duration, leaving 10% as a pause 159 | tone(buzzer, melody[thisNote], noteDuration * 0.9); 160 | 161 | // Wait for the specief duration before playing the next note. 162 | delay(noteDuration); 163 | 164 | // stop the waveform generation before the next note. 165 | noTone(buzzer); 166 | } 167 | } 168 | 169 | void loop() { 170 | // no need to repeat the melody. 171 | } 172 | -------------------------------------------------------------------------------- /brahmslullaby/brahmslullaby.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Brahms' Lullaby (Wiegenlied) - Johannes Brahms 3 | Connect a piezo buzzer or speaker to pin 11 or select a new pin. 4 | More songs available at https://github.com/robsoncouto/arduino-songs 5 | 6 | Robson Couto, 2019 7 | */ 8 | #define NOTE_B0 31 9 | #define NOTE_C1 33 10 | #define NOTE_CS1 35 11 | #define NOTE_D1 37 12 | #define NOTE_DS1 39 13 | #define NOTE_E1 41 14 | #define NOTE_F1 44 15 | #define NOTE_FS1 46 16 | #define NOTE_G1 49 17 | #define NOTE_GS1 52 18 | #define NOTE_A1 55 19 | #define NOTE_AS1 58 20 | #define NOTE_B1 62 21 | #define NOTE_C2 65 22 | #define NOTE_CS2 69 23 | #define NOTE_D2 73 24 | #define NOTE_DS2 78 25 | #define NOTE_E2 82 26 | #define NOTE_F2 87 27 | #define NOTE_FS2 93 28 | #define NOTE_G2 98 29 | #define NOTE_GS2 104 30 | #define NOTE_A2 110 31 | #define NOTE_AS2 117 32 | #define NOTE_B2 123 33 | #define NOTE_C3 131 34 | #define NOTE_CS3 139 35 | #define NOTE_D3 147 36 | #define NOTE_DS3 156 37 | #define NOTE_E3 165 38 | #define NOTE_F3 175 39 | #define NOTE_FS3 185 40 | #define NOTE_G3 196 41 | #define NOTE_GS3 208 42 | #define NOTE_A3 220 43 | #define NOTE_AS3 233 44 | #define NOTE_B3 247 45 | #define NOTE_C4 262 46 | #define NOTE_CS4 277 47 | #define NOTE_D4 294 48 | #define NOTE_DS4 311 49 | #define NOTE_E4 330 50 | #define NOTE_F4 349 51 | #define NOTE_FS4 370 52 | #define NOTE_G4 392 53 | #define NOTE_GS4 415 54 | #define NOTE_A4 440 55 | #define NOTE_AS4 466 56 | #define NOTE_B4 494 57 | #define NOTE_C5 523 58 | #define NOTE_CS5 554 59 | #define NOTE_D5 587 60 | #define NOTE_DS5 622 61 | #define NOTE_E5 659 62 | #define NOTE_F5 698 63 | #define NOTE_FS5 740 64 | #define NOTE_G5 784 65 | #define NOTE_GS5 831 66 | #define NOTE_A5 880 67 | #define NOTE_AS5 932 68 | #define NOTE_B5 988 69 | #define NOTE_C6 1047 70 | #define NOTE_CS6 1109 71 | #define NOTE_D6 1175 72 | #define NOTE_DS6 1245 73 | #define NOTE_E6 1319 74 | #define NOTE_F6 1397 75 | #define NOTE_FS6 1480 76 | #define NOTE_G6 1568 77 | #define NOTE_GS6 1661 78 | #define NOTE_A6 1760 79 | #define NOTE_AS6 1865 80 | #define NOTE_B6 1976 81 | #define NOTE_C7 2093 82 | #define NOTE_CS7 2217 83 | #define NOTE_D7 2349 84 | #define NOTE_DS7 2489 85 | #define NOTE_E7 2637 86 | #define NOTE_F7 2794 87 | #define NOTE_FS7 2960 88 | #define NOTE_G7 3136 89 | #define NOTE_GS7 3322 90 | #define NOTE_A7 3520 91 | #define NOTE_AS7 3729 92 | #define NOTE_B7 3951 93 | #define NOTE_C8 4186 94 | #define NOTE_CS8 4435 95 | #define NOTE_D8 4699 96 | #define NOTE_DS8 4978 97 | #define REST 0 98 | 99 | 100 | // change this to make the song slower or faster 101 | int tempo = 76; 102 | 103 | // change this to whichever pin you want to use 104 | int buzzer = 11; 105 | 106 | // notes of the moledy followed by the duration. 107 | // a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on 108 | // !!negative numbers are used to represent dotted notes, 109 | // so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!! 110 | int melody[] = { 111 | 112 | // Wiegenlied (Brahms' Lullaby) 113 | // Score available at https://www.flutetunes.com/tunes.php?id=54 114 | 115 | NOTE_G4, 4, NOTE_G4, 4, //1 116 | NOTE_AS4, -4, NOTE_G4, 8, NOTE_G4, 4, 117 | NOTE_AS4, 4, REST, 4, NOTE_G4, 8, NOTE_AS4, 8, 118 | NOTE_DS5, 4, NOTE_D5, -4, NOTE_C5, 8, 119 | NOTE_C5, 4, NOTE_AS4, 4, NOTE_F4, 8, NOTE_G4, 8, 120 | NOTE_GS4, 4, NOTE_F4, 4, NOTE_F4, 8, NOTE_G4, 8, 121 | NOTE_GS4, 4, REST, 4, NOTE_F4, 8, NOTE_GS4, 8, 122 | NOTE_D5, 8, NOTE_C5, 8, NOTE_AS4, 4, NOTE_D5, 4, 123 | 124 | NOTE_DS5, 4, REST, 4, NOTE_DS4, 8, NOTE_DS4, 8, //8 125 | NOTE_DS5, 2, NOTE_C5, 8, NOTE_GS4, 8, 126 | NOTE_AS4, 2, NOTE_G4, 8, NOTE_DS4, 8, 127 | NOTE_GS4, 4, NOTE_AS4, 4, NOTE_C5, 4, 128 | NOTE_AS4, 2, NOTE_DS4, 8, NOTE_DS4, 8, 129 | NOTE_DS5, 2, NOTE_C5, 8, NOTE_GS4, 8, 130 | NOTE_AS4, 2, NOTE_G4, 8, NOTE_DS4, 8, 131 | NOTE_AS4, 4, NOTE_G4, 4, NOTE_DS4, 4, 132 | NOTE_DS4, 2 133 | 134 | }; 135 | 136 | // sizeof gives the number of bytes, each int valsmaue is composed of two bytes (16 bits) 137 | // there are two values per note (pitch and duration), so for each note there are four bytes 138 | int notes = sizeof(melody) / sizeof(melody[0]) / 2; 139 | 140 | // this calculates the duration of a whole note in ms 141 | int wholenote = (60000 * 4) / tempo; 142 | 143 | int divider = 0, noteDuration = 0; 144 | 145 | void setup() { 146 | // iterate over the notes of the melody. 147 | // Remember, the array is twice the number of notes (notes + durations) 148 | for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) { 149 | 150 | // calculates the duration of each note 151 | divider = melody[thisNote + 1]; 152 | if (divider > 0) { 153 | // regular note, just proceed 154 | noteDuration = (wholenote) / divider; 155 | } else if (divider < 0) { 156 | // dotted notes are represented with negative durations!! 157 | noteDuration = (wholenote) / abs(divider); 158 | noteDuration *= 1.5; // increases the duration in half for dotted notes 159 | } 160 | 161 | // we only play the note for 90% of the duration, leaving 10% as a pause 162 | tone(buzzer, melody[thisNote], noteDuration * 0.9); 163 | 164 | // Wait for the specief duration before playing the next note. 165 | delay(noteDuration); 166 | 167 | // stop the waveform generation before the next note. 168 | noTone(buzzer); 169 | } 170 | } 171 | 172 | void loop() { 173 | // no need to repeat the melody. 174 | } 175 | -------------------------------------------------------------------------------- /zeldaslullaby/zeldaslullaby.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Zelda's Lullaby 3 | Connect a piezo buzzer or speaker to pin 11 or select a new pin. 4 | More songs available at https://github.com/robsoncouto/arduino-songs 5 | 6 | Robson Couto, 2019 7 | */ 8 | 9 | #define NOTE_B0 31 10 | #define NOTE_C1 33 11 | #define NOTE_CS1 35 12 | #define NOTE_D1 37 13 | #define NOTE_DS1 39 14 | #define NOTE_E1 41 15 | #define NOTE_F1 44 16 | #define NOTE_FS1 46 17 | #define NOTE_G1 49 18 | #define NOTE_GS1 52 19 | #define NOTE_A1 55 20 | #define NOTE_AS1 58 21 | #define NOTE_B1 62 22 | #define NOTE_C2 65 23 | #define NOTE_CS2 69 24 | #define NOTE_D2 73 25 | #define NOTE_DS2 78 26 | #define NOTE_E2 82 27 | #define NOTE_F2 87 28 | #define NOTE_FS2 93 29 | #define NOTE_G2 98 30 | #define NOTE_GS2 104 31 | #define NOTE_A2 110 32 | #define NOTE_AS2 117 33 | #define NOTE_B2 123 34 | #define NOTE_C3 131 35 | #define NOTE_CS3 139 36 | #define NOTE_D3 147 37 | #define NOTE_DS3 156 38 | #define NOTE_E3 165 39 | #define NOTE_F3 175 40 | #define NOTE_FS3 185 41 | #define NOTE_G3 196 42 | #define NOTE_GS3 208 43 | #define NOTE_A3 220 44 | #define NOTE_AS3 233 45 | #define NOTE_B3 247 46 | #define NOTE_C4 262 47 | #define NOTE_CS4 277 48 | #define NOTE_D4 294 49 | #define NOTE_DS4 311 50 | #define NOTE_E4 330 51 | #define NOTE_F4 349 52 | #define NOTE_FS4 370 53 | #define NOTE_G4 392 54 | #define NOTE_GS4 415 55 | #define NOTE_A4 440 56 | #define NOTE_AS4 466 57 | #define NOTE_B4 494 58 | #define NOTE_C5 523 59 | #define NOTE_CS5 554 60 | #define NOTE_D5 587 61 | #define NOTE_DS5 622 62 | #define NOTE_E5 659 63 | #define NOTE_F5 698 64 | #define NOTE_FS5 740 65 | #define NOTE_G5 784 66 | #define NOTE_GS5 831 67 | #define NOTE_A5 880 68 | #define NOTE_AS5 932 69 | #define NOTE_B5 988 70 | #define NOTE_C6 1047 71 | #define NOTE_CS6 1109 72 | #define NOTE_D6 1175 73 | #define NOTE_DS6 1245 74 | #define NOTE_E6 1319 75 | #define NOTE_F6 1397 76 | #define NOTE_FS6 1480 77 | #define NOTE_G6 1568 78 | #define NOTE_GS6 1661 79 | #define NOTE_A6 1760 80 | #define NOTE_AS6 1865 81 | #define NOTE_B6 1976 82 | #define NOTE_C7 2093 83 | #define NOTE_CS7 2217 84 | #define NOTE_D7 2349 85 | #define NOTE_DS7 2489 86 | #define NOTE_E7 2637 87 | #define NOTE_F7 2794 88 | #define NOTE_FS7 2960 89 | #define NOTE_G7 3136 90 | #define NOTE_GS7 3322 91 | #define NOTE_A7 3520 92 | #define NOTE_AS7 3729 93 | #define NOTE_B7 3951 94 | #define NOTE_C8 4186 95 | #define NOTE_CS8 4435 96 | #define NOTE_D8 4699 97 | #define NOTE_DS8 4978 98 | #define REST 0 99 | 100 | 101 | // change this to make the song slower or faster 102 | int tempo = 108; 103 | 104 | // change this to whichever pin you want to use 105 | int buzzer = 11; 106 | 107 | // notes of the moledy followed by the duration. 108 | // a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on 109 | // !!negative numbers are used to represent dotted notes, 110 | // so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!! 111 | int melody[] = { 112 | 113 | // Zelda's Lullaby - The Legend of Zelda Ocarina of Time. 114 | // Score available at https://musescore.com/user/12754451/scores/2762776 115 | 116 | NOTE_E4,2, NOTE_G4,4, 117 | NOTE_D4,2, NOTE_C4,8, NOTE_D4,8, 118 | NOTE_E4,2, NOTE_G4,4, 119 | NOTE_D4,-2, 120 | NOTE_E4,2, NOTE_G4,4, 121 | NOTE_D5,2, NOTE_C5,4, 122 | NOTE_G4,2, NOTE_F4,8, NOTE_E4,8, 123 | NOTE_D4,-2, 124 | NOTE_E4,2, NOTE_G4,4, 125 | NOTE_D4,2, NOTE_C4,8, NOTE_D4,8, 126 | NOTE_E4,2, NOTE_G4,4, 127 | NOTE_D4,-2, 128 | NOTE_E4,2, NOTE_G4,4, 129 | 130 | NOTE_D5,2, NOTE_C5,4, 131 | NOTE_G4,2, NOTE_F4,8, NOTE_E4,8, 132 | NOTE_F4,8, NOTE_E4,8, NOTE_C4,2, 133 | NOTE_F4,2, NOTE_E4,8, NOTE_D4,8, 134 | NOTE_E4,8, NOTE_D4,8, NOTE_A3,2, 135 | NOTE_G4,2, NOTE_F4,8, NOTE_E4,8, 136 | NOTE_F4,8, NOTE_E4,8, NOTE_C4,4, NOTE_F4,4, 137 | NOTE_C5,-2, 138 | 139 | }; 140 | 141 | // sizeof gives the number of bytes, each int value is composed of two bytes (16 bits) 142 | // there are two values per note (pitch and duration), so for each note there are four bytes 143 | int notes = sizeof(melody) / sizeof(melody[0]) / 2; 144 | 145 | // this calculates the duration of a whole note in ms 146 | int wholenote = (60000 * 4) / tempo; 147 | 148 | int divider = 0, noteDuration = 0; 149 | 150 | void setup() { 151 | // iterate over the notes of the melody. 152 | // Remember, the array is twice the number of notes (notes + durations) 153 | for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) { 154 | 155 | // calculates the duration of each note 156 | divider = melody[thisNote + 1]; 157 | if (divider > 0) { 158 | // regular note, just proceed 159 | noteDuration = (wholenote) / divider; 160 | } else if (divider < 0) { 161 | // dotted notes are represented with negative durations!! 162 | noteDuration = (wholenote) / abs(divider); 163 | noteDuration *= 1.5; // increases the duration in half for dotted notes 164 | } 165 | 166 | // we only play the note for 90% of the duration, leaving 10% as a pause 167 | tone(buzzer, melody[thisNote], noteDuration*0.9); 168 | 169 | // Wait for the specief duration before playing the next note. 170 | delay(noteDuration); 171 | 172 | // stop the waveform generation before the next note. 173 | noTone(buzzer); 174 | } 175 | } 176 | 177 | void loop() { 178 | // no need to repeat the melody. 179 | } 180 | -------------------------------------------------------------------------------- /silentnight/silentnight.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Silent Night 3 | Connect a piezo buzzer or speaker to pin 11 or select a new pin. 4 | More songs available at https://github.com/robsoncouto/arduino-songs 5 | 6 | Robson Couto, 2019 7 | */ 8 | #define NOTE_B0 31 9 | #define NOTE_C1 33 10 | #define NOTE_CS1 35 11 | #define NOTE_D1 37 12 | #define NOTE_DS1 39 13 | #define NOTE_E1 41 14 | #define NOTE_F1 44 15 | #define NOTE_FS1 46 16 | #define NOTE_G1 49 17 | #define NOTE_GS1 52 18 | #define NOTE_A1 55 19 | #define NOTE_AS1 58 20 | #define NOTE_B1 62 21 | #define NOTE_C2 65 22 | #define NOTE_CS2 69 23 | #define NOTE_D2 73 24 | #define NOTE_DS2 78 25 | #define NOTE_E2 82 26 | #define NOTE_F2 87 27 | #define NOTE_FS2 93 28 | #define NOTE_G2 98 29 | #define NOTE_GS2 104 30 | #define NOTE_A2 110 31 | #define NOTE_AS2 117 32 | #define NOTE_B2 123 33 | #define NOTE_C3 131 34 | #define NOTE_CS3 139 35 | #define NOTE_D3 147 36 | #define NOTE_DS3 156 37 | #define NOTE_E3 165 38 | #define NOTE_F3 175 39 | #define NOTE_FS3 185 40 | #define NOTE_G3 196 41 | #define NOTE_GS3 208 42 | #define NOTE_A3 220 43 | #define NOTE_AS3 233 44 | #define NOTE_B3 247 45 | #define NOTE_C4 262 46 | #define NOTE_CS4 277 47 | #define NOTE_D4 294 48 | #define NOTE_DS4 311 49 | #define NOTE_E4 330 50 | #define NOTE_F4 349 51 | #define NOTE_FS4 370 52 | #define NOTE_G4 392 53 | #define NOTE_GS4 415 54 | #define NOTE_A4 440 55 | #define NOTE_AS4 466 56 | #define NOTE_B4 494 57 | #define NOTE_C5 523 58 | #define NOTE_CS5 554 59 | #define NOTE_D5 587 60 | #define NOTE_DS5 622 61 | #define NOTE_E5 659 62 | #define NOTE_F5 698 63 | #define NOTE_FS5 740 64 | #define NOTE_G5 784 65 | #define NOTE_GS5 831 66 | #define NOTE_A5 880 67 | #define NOTE_AS5 932 68 | #define NOTE_B5 988 69 | #define NOTE_C6 1047 70 | #define NOTE_CS6 1109 71 | #define NOTE_D6 1175 72 | #define NOTE_DS6 1245 73 | #define NOTE_E6 1319 74 | #define NOTE_F6 1397 75 | #define NOTE_FS6 1480 76 | #define NOTE_G6 1568 77 | #define NOTE_GS6 1661 78 | #define NOTE_A6 1760 79 | #define NOTE_AS6 1865 80 | #define NOTE_B6 1976 81 | #define NOTE_C7 2093 82 | #define NOTE_CS7 2217 83 | #define NOTE_D7 2349 84 | #define NOTE_DS7 2489 85 | #define NOTE_E7 2637 86 | #define NOTE_F7 2794 87 | #define NOTE_FS7 2960 88 | #define NOTE_G7 3136 89 | #define NOTE_GS7 3322 90 | #define NOTE_A7 3520 91 | #define NOTE_AS7 3729 92 | #define NOTE_B7 3951 93 | #define NOTE_C8 4186 94 | #define NOTE_CS8 4435 95 | #define NOTE_D8 4699 96 | #define NOTE_DS8 4978 97 | #define REST 0 98 | 99 | 100 | // change this to make the song slower or faster 101 | int tempo = 140; 102 | 103 | // change this to whichever pin you want to use 104 | int buzzer = 11; 105 | 106 | // notes of the moledy followed by the duration. 107 | // a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on 108 | // !!negative numbers are used to represent dotted notes, 109 | // so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!! 110 | int melody[] = { 111 | 112 | // Silent Night, Original Version 113 | // Score available at https://musescore.com/marcsabatella/scores/3123436 114 | 115 | NOTE_G4,-4, NOTE_A4,8, NOTE_G4,4, 116 | NOTE_E4,-2, 117 | NOTE_G4,-4, NOTE_A4,8, NOTE_G4,4, 118 | NOTE_E4,-2, 119 | NOTE_D5,2, NOTE_D5,4, 120 | NOTE_B4,-2, 121 | NOTE_C5,2, NOTE_C5,4, 122 | NOTE_G4,-2, 123 | 124 | NOTE_A4,2, NOTE_A4,4, 125 | NOTE_C5,-4, NOTE_B4,8, NOTE_A4,4, 126 | NOTE_G4,-4, NOTE_A4,8, NOTE_G4,4, 127 | NOTE_E4,-2, 128 | NOTE_A4,2, NOTE_A4,4, 129 | NOTE_C5,-4, NOTE_B4,8, NOTE_A4,4, 130 | NOTE_G4,-4, NOTE_A4,8, NOTE_G4,4, 131 | NOTE_E4,-2, 132 | 133 | NOTE_D5,2, NOTE_D5,4, 134 | NOTE_F5,-4, NOTE_D5,8, NOTE_B4,4, 135 | NOTE_C5,-2, 136 | NOTE_E5,-2, 137 | NOTE_C5,4, NOTE_G4,4, NOTE_E4,4, 138 | NOTE_G4,-4, NOTE_F4,8, NOTE_D4,4, 139 | NOTE_C4,-2, 140 | NOTE_C4,-1, 141 | 142 | 143 | 144 | 145 | 146 | 147 | }; 148 | 149 | // sizeof gives the number of bytes, each int value is composed of two bytes (16 bits) 150 | // there are two values per note (pitch and duration), so for each note there are four bytes 151 | int notes = sizeof(melody) / sizeof(melody[0]) / 2; 152 | 153 | // this calculates the duration of a whole note in ms 154 | int wholenote = (60000 * 4) / tempo; 155 | 156 | int divider = 0, noteDuration = 0; 157 | 158 | void setup() { 159 | // iterate over the notes of the melody. 160 | // Remember, the array is twice the number of notes (notes + durations) 161 | for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) { 162 | 163 | // calculates the duration of each note 164 | divider = melody[thisNote + 1]; 165 | if (divider > 0) { 166 | // regular note, just proceed 167 | noteDuration = (wholenote) / divider; 168 | } else if (divider < 0) { 169 | // dotted notes are represented with negative durations!! 170 | noteDuration = (wholenote) / abs(divider); 171 | noteDuration *= 1.5; // increases the duration in half for dotted notes 172 | } 173 | 174 | // we only play the note for 90% of the duration, leaving 10% as a pause 175 | tone(buzzer, melody[thisNote], noteDuration * 0.9); 176 | 177 | // Wait for the specief duration before playing the next note. 178 | delay(noteDuration); 179 | 180 | // stop the waveform generation before the next note. 181 | noTone(buzzer); 182 | } 183 | } 184 | 185 | void loop() { 186 | // no need to repeat the melody. 187 | } 188 | -------------------------------------------------------------------------------- /keyboardcat/keyboardcat.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Keyboard cat 3 | Connect a piezo buzzer or speaker to pin 11 or select a new pin. 4 | More songs available at https://github.com/robsoncouto/arduino-songs 5 | 6 | Robson Couto, 2019 7 | */ 8 | #define NOTE_B0 31 9 | #define NOTE_C1 33 10 | #define NOTE_CS1 35 11 | #define NOTE_D1 37 12 | #define NOTE_DS1 39 13 | #define NOTE_E1 41 14 | #define NOTE_F1 44 15 | #define NOTE_FS1 46 16 | #define NOTE_G1 49 17 | #define NOTE_GS1 52 18 | #define NOTE_A1 55 19 | #define NOTE_AS1 58 20 | #define NOTE_B1 62 21 | #define NOTE_C2 65 22 | #define NOTE_CS2 69 23 | #define NOTE_D2 73 24 | #define NOTE_DS2 78 25 | #define NOTE_E2 82 26 | #define NOTE_F2 87 27 | #define NOTE_FS2 93 28 | #define NOTE_G2 98 29 | #define NOTE_GS2 104 30 | #define NOTE_A2 110 31 | #define NOTE_AS2 117 32 | #define NOTE_B2 123 33 | #define NOTE_C3 131 34 | #define NOTE_CS3 139 35 | #define NOTE_D3 147 36 | #define NOTE_DS3 156 37 | #define NOTE_E3 165 38 | #define NOTE_F3 175 39 | #define NOTE_FS3 185 40 | #define NOTE_G3 196 41 | #define NOTE_GS3 208 42 | #define NOTE_A3 220 43 | #define NOTE_AS3 233 44 | #define NOTE_B3 247 45 | #define NOTE_C4 262 46 | #define NOTE_CS4 277 47 | #define NOTE_D4 294 48 | #define NOTE_DS4 311 49 | #define NOTE_E4 330 50 | #define NOTE_F4 349 51 | #define NOTE_FS4 370 52 | #define NOTE_G4 392 53 | #define NOTE_GS4 415 54 | #define NOTE_A4 440 55 | #define NOTE_AS4 466 56 | #define NOTE_B4 494 57 | #define NOTE_C5 523 58 | #define NOTE_CS5 554 59 | #define NOTE_D5 587 60 | #define NOTE_DS5 622 61 | #define NOTE_E5 659 62 | #define NOTE_F5 698 63 | #define NOTE_FS5 740 64 | #define NOTE_G5 784 65 | #define NOTE_GS5 831 66 | #define NOTE_A5 880 67 | #define NOTE_AS5 932 68 | #define NOTE_B5 988 69 | #define NOTE_C6 1047 70 | #define NOTE_CS6 1109 71 | #define NOTE_D6 1175 72 | #define NOTE_DS6 1245 73 | #define NOTE_E6 1319 74 | #define NOTE_F6 1397 75 | #define NOTE_FS6 1480 76 | #define NOTE_G6 1568 77 | #define NOTE_GS6 1661 78 | #define NOTE_A6 1760 79 | #define NOTE_AS6 1865 80 | #define NOTE_B6 1976 81 | #define NOTE_C7 2093 82 | #define NOTE_CS7 2217 83 | #define NOTE_D7 2349 84 | #define NOTE_DS7 2489 85 | #define NOTE_E7 2637 86 | #define NOTE_F7 2794 87 | #define NOTE_FS7 2960 88 | #define NOTE_G7 3136 89 | #define NOTE_GS7 3322 90 | #define NOTE_A7 3520 91 | #define NOTE_AS7 3729 92 | #define NOTE_B7 3951 93 | #define NOTE_C8 4186 94 | #define NOTE_CS8 4435 95 | #define NOTE_D8 4699 96 | #define NOTE_DS8 4978 97 | #define REST 0 98 | 99 | 100 | // change this to make the song slower or faster 101 | int tempo = 160; 102 | 103 | // change this to whichever pin you want to use 104 | int buzzer = 11; 105 | 106 | // notes of the moledy followed by the duration. 107 | // a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on 108 | // !!negative numbers are used to represent dotted notes, 109 | // so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!! 110 | int melody[] = { 111 | 112 | // Keyboard cat 113 | // Score available at https://musescore.com/user/142788/scores/147371 114 | 115 | REST,1, 116 | REST,1, 117 | NOTE_C4,4, NOTE_E4,4, NOTE_G4,4, NOTE_E4,4, 118 | NOTE_C4,4, NOTE_E4,8, NOTE_G4,-4, NOTE_E4,4, 119 | NOTE_A3,4, NOTE_C4,4, NOTE_E4,4, NOTE_C4,4, 120 | NOTE_A3,4, NOTE_C4,8, NOTE_E4,-4, NOTE_C4,4, 121 | NOTE_G3,4, NOTE_B3,4, NOTE_D4,4, NOTE_B3,4, 122 | NOTE_G3,4, NOTE_B3,8, NOTE_D4,-4, NOTE_B3,4, 123 | 124 | NOTE_G3,4, NOTE_G3,8, NOTE_G3,-4, NOTE_G3,8, NOTE_G3,4, 125 | NOTE_G3,4, NOTE_G3,4, NOTE_G3,8, NOTE_G3,4, 126 | NOTE_C4,4, NOTE_E4,4, NOTE_G4,4, NOTE_E4,4, 127 | NOTE_C4,4, NOTE_E4,8, NOTE_G4,-4, NOTE_E4,4, 128 | NOTE_A3,4, NOTE_C4,4, NOTE_E4,4, NOTE_C4,4, 129 | NOTE_A3,4, NOTE_C4,8, NOTE_E4,-4, NOTE_C4,4, 130 | NOTE_G3,4, NOTE_B3,4, NOTE_D4,4, NOTE_B3,4, 131 | NOTE_G3,4, NOTE_B3,8, NOTE_D4,-4, NOTE_B3,4, 132 | 133 | NOTE_G3,-1, 134 | 135 | }; 136 | 137 | // sizeof gives the number of bytes, each int value is composed of two bytes (16 bits) 138 | // there are two values per note (pitch and duration), so for each note there are four bytes 139 | int notes = sizeof(melody) / sizeof(melody[0]) / 2; 140 | 141 | // this calculates the duration of a whole note in ms 142 | int wholenote = (60000 * 4) / tempo; 143 | 144 | int divider = 0, noteDuration = 0; 145 | 146 | void setup() { 147 | // iterate over the notes of the melody. 148 | // Remember, the array is twice the number of notes (notes + durations) 149 | for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) { 150 | 151 | // calculates the duration of each note 152 | divider = melody[thisNote + 1]; 153 | if (divider > 0) { 154 | // regular note, just proceed 155 | noteDuration = (wholenote) / divider; 156 | } else if (divider < 0) { 157 | // dotted notes are represented with negative durations!! 158 | noteDuration = (wholenote) / abs(divider); 159 | noteDuration *= 1.5; // increases the duration in half for dotted notes 160 | } 161 | 162 | // we only play the note for 90% of the duration, leaving 10% as a pause 163 | tone(buzzer, melody[thisNote], noteDuration * 0.9); 164 | 165 | // Wait for the specief duration before playing the next note. 166 | delay(noteDuration); 167 | 168 | // stop the waveform generation before the next note. 169 | noTone(buzzer); 170 | } 171 | } 172 | 173 | void loop() { 174 | // no need to repeat the melody. 175 | } 176 | -------------------------------------------------------------------------------- /babyelephantwalk/babyelephantwalk.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Baby Elephant Walk 3 | Connect a piezo buzzer or speaker to pin 11 or select a new pin. 4 | More songs available at https://github.com/robsoncouto/arduino-songs 5 | 6 | Robson Couto, 2019 7 | */ 8 | #define NOTE_B0 31 9 | #define NOTE_C1 33 10 | #define NOTE_CS1 35 11 | #define NOTE_D1 37 12 | #define NOTE_DS1 39 13 | #define NOTE_E1 41 14 | #define NOTE_F1 44 15 | #define NOTE_FS1 46 16 | #define NOTE_G1 49 17 | #define NOTE_GS1 52 18 | #define NOTE_A1 55 19 | #define NOTE_AS1 58 20 | #define NOTE_B1 62 21 | #define NOTE_C2 65 22 | #define NOTE_CS2 69 23 | #define NOTE_D2 73 24 | #define NOTE_DS2 78 25 | #define NOTE_E2 82 26 | #define NOTE_F2 87 27 | #define NOTE_FS2 93 28 | #define NOTE_G2 98 29 | #define NOTE_GS2 104 30 | #define NOTE_A2 110 31 | #define NOTE_AS2 117 32 | #define NOTE_B2 123 33 | #define NOTE_C3 131 34 | #define NOTE_CS3 139 35 | #define NOTE_D3 147 36 | #define NOTE_DS3 156 37 | #define NOTE_E3 165 38 | #define NOTE_F3 175 39 | #define NOTE_FS3 185 40 | #define NOTE_G3 196 41 | #define NOTE_GS3 208 42 | #define NOTE_A3 220 43 | #define NOTE_AS3 233 44 | #define NOTE_B3 247 45 | #define NOTE_C4 262 46 | #define NOTE_CS4 277 47 | #define NOTE_D4 294 48 | #define NOTE_DS4 311 49 | #define NOTE_E4 330 50 | #define NOTE_F4 349 51 | #define NOTE_FS4 370 52 | #define NOTE_G4 392 53 | #define NOTE_GS4 415 54 | #define NOTE_A4 440 55 | #define NOTE_AS4 466 56 | #define NOTE_B4 494 57 | #define NOTE_C5 523 58 | #define NOTE_CS5 554 59 | #define NOTE_D5 587 60 | #define NOTE_DS5 622 61 | #define NOTE_E5 659 62 | #define NOTE_F5 698 63 | #define NOTE_FS5 740 64 | #define NOTE_G5 784 65 | #define NOTE_GS5 831 66 | #define NOTE_A5 880 67 | #define NOTE_AS5 932 68 | #define NOTE_B5 988 69 | #define NOTE_C6 1047 70 | #define NOTE_CS6 1109 71 | #define NOTE_D6 1175 72 | #define NOTE_DS6 1245 73 | #define NOTE_E6 1319 74 | #define NOTE_F6 1397 75 | #define NOTE_FS6 1480 76 | #define NOTE_G6 1568 77 | #define NOTE_GS6 1661 78 | #define NOTE_A6 1760 79 | #define NOTE_AS6 1865 80 | #define NOTE_B6 1976 81 | #define NOTE_C7 2093 82 | #define NOTE_CS7 2217 83 | #define NOTE_D7 2349 84 | #define NOTE_DS7 2489 85 | #define NOTE_E7 2637 86 | #define NOTE_F7 2794 87 | #define NOTE_FS7 2960 88 | #define NOTE_G7 3136 89 | #define NOTE_GS7 3322 90 | #define NOTE_A7 3520 91 | #define NOTE_AS7 3729 92 | #define NOTE_B7 3951 93 | #define NOTE_C8 4186 94 | #define NOTE_CS8 4435 95 | #define NOTE_D8 4699 96 | #define NOTE_DS8 4978 97 | #define REST 0 98 | 99 | 100 | // change this to make the song slower or faster 101 | int tempo = 132; 102 | 103 | // change this to whichever pin you want to use 104 | int buzzer = 11; 105 | 106 | // notes of the moledy followed by the duration. 107 | // a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on 108 | // !!negative numbers are used to represent dotted notes, 109 | // so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!! 110 | int melody[] = { 111 | 112 | // Baby Elephant Walk 113 | // Score available at https://musescore.com/user/7965776/scores/1862611 114 | 115 | 116 | NOTE_C4,-8, NOTE_E4,16, NOTE_G4,8, NOTE_C5,8, NOTE_E5,8, NOTE_D5,8, NOTE_C5,8, NOTE_A4,8, 117 | NOTE_FS4,8, NOTE_G4,8, REST,4, REST,2, 118 | NOTE_C4,-8, NOTE_E4,16, NOTE_G4,8, NOTE_C5,8, NOTE_E5,8, NOTE_D5,8, NOTE_C5,8, NOTE_A4,8, 119 | NOTE_G4,-2, NOTE_A4,8, NOTE_DS4,1, 120 | 121 | NOTE_A4,8, 122 | NOTE_E4,8, NOTE_C4,8, REST,4, REST,2, 123 | NOTE_C4,-8, NOTE_E4,16, NOTE_G4,8, NOTE_C5,8, NOTE_E5,8, NOTE_D5,8, NOTE_C5,8, NOTE_A4,8, 124 | NOTE_FS4,8, NOTE_G4,8, REST,4, REST,4, REST,8, NOTE_G4,8, 125 | NOTE_D5,4, NOTE_D5,4, NOTE_B4,8, NOTE_G4,8, REST,8, NOTE_G4,8, 126 | 127 | NOTE_C5,4, NOTE_C5,4, NOTE_AS4,16, NOTE_C5,16, NOTE_AS4,16, NOTE_G4,16, NOTE_F4,8, NOTE_DS4,8, 128 | NOTE_FS4,4, NOTE_FS4,4, NOTE_F4,16, NOTE_G4,16, NOTE_F4,16, NOTE_DS4,16, NOTE_C4,8, NOTE_G4,8, 129 | NOTE_AS4,8, NOTE_C5,8, REST,4, REST,2, 130 | }; 131 | 132 | // sizeof gives the number of bytes, each int value is composed of two bytes (16 bits) 133 | // there are two values per note (pitch and duration), so for each note there are four bytes 134 | int notes = sizeof(melody) / sizeof(melody[0]) / 2; 135 | 136 | // this calculates the duration of a whole note in ms 137 | int wholenote = (60000 * 4) / tempo; 138 | 139 | int divider = 0, noteDuration = 0; 140 | 141 | void setup() { 142 | // iterate over the notes of the melody. 143 | // Remember, the array is twice the number of notes (notes + durations) 144 | for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) { 145 | 146 | // calculates the duration of each note 147 | divider = melody[thisNote + 1]; 148 | if (divider > 0) { 149 | // regular note, just proceed 150 | noteDuration = (wholenote) / divider; 151 | } else if (divider < 0) { 152 | // dotted notes are represented with negative durations!! 153 | noteDuration = (wholenote) / abs(divider); 154 | noteDuration *= 1.5; // increases the duration in half for dotted notes 155 | } 156 | 157 | // we only play the note for 90% of the duration, leaving 10% as a pause 158 | tone(buzzer, melody[thisNote], noteDuration * 0.9); 159 | 160 | // Wait for the specief duration before playing the next note. 161 | delay(noteDuration); 162 | 163 | // stop the waveform generation before the next note. 164 | noTone(buzzer); 165 | } 166 | } 167 | 168 | void loop() { 169 | // no need to repeat the melody. 170 | } 171 | -------------------------------------------------------------------------------- /odetojoy/odetojoy.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Ode to Joy - Beethoven's Symphony No. 9 3 | Connect a piezo buzzer or speaker to pin 11 or select a new pin. 4 | More songs available at https://github.com/robsoncouto/arduino-songs 5 | 6 | Robson Couto, 2019 7 | */ 8 | 9 | #define NOTE_B0 31 10 | #define NOTE_C1 33 11 | #define NOTE_CS1 35 12 | #define NOTE_D1 37 13 | #define NOTE_DS1 39 14 | #define NOTE_E1 41 15 | #define NOTE_F1 44 16 | #define NOTE_FS1 46 17 | #define NOTE_G1 49 18 | #define NOTE_GS1 52 19 | #define NOTE_A1 55 20 | #define NOTE_AS1 58 21 | #define NOTE_B1 62 22 | #define NOTE_C2 65 23 | #define NOTE_CS2 69 24 | #define NOTE_D2 73 25 | #define NOTE_DS2 78 26 | #define NOTE_E2 82 27 | #define NOTE_F2 87 28 | #define NOTE_FS2 93 29 | #define NOTE_G2 98 30 | #define NOTE_GS2 104 31 | #define NOTE_A2 110 32 | #define NOTE_AS2 117 33 | #define NOTE_B2 123 34 | #define NOTE_C3 131 35 | #define NOTE_CS3 139 36 | #define NOTE_D3 147 37 | #define NOTE_DS3 156 38 | #define NOTE_E3 165 39 | #define NOTE_F3 175 40 | #define NOTE_FS3 185 41 | #define NOTE_G3 196 42 | #define NOTE_GS3 208 43 | #define NOTE_A3 220 44 | #define NOTE_AS3 233 45 | #define NOTE_B3 247 46 | #define NOTE_C4 262 47 | #define NOTE_CS4 277 48 | #define NOTE_D4 294 49 | #define NOTE_DS4 311 50 | #define NOTE_E4 330 51 | #define NOTE_F4 349 52 | #define NOTE_FS4 370 53 | #define NOTE_G4 392 54 | #define NOTE_GS4 415 55 | #define NOTE_A4 440 56 | #define NOTE_AS4 466 57 | #define NOTE_B4 494 58 | #define NOTE_C5 523 59 | #define NOTE_CS5 554 60 | #define NOTE_D5 587 61 | #define NOTE_DS5 622 62 | #define NOTE_E5 659 63 | #define NOTE_F5 698 64 | #define NOTE_FS5 740 65 | #define NOTE_G5 784 66 | #define NOTE_GS5 831 67 | #define NOTE_A5 880 68 | #define NOTE_AS5 932 69 | #define NOTE_B5 988 70 | #define NOTE_C6 1047 71 | #define NOTE_CS6 1109 72 | #define NOTE_D6 1175 73 | #define NOTE_DS6 1245 74 | #define NOTE_E6 1319 75 | #define NOTE_F6 1397 76 | #define NOTE_FS6 1480 77 | #define NOTE_G6 1568 78 | #define NOTE_GS6 1661 79 | #define NOTE_A6 1760 80 | #define NOTE_AS6 1865 81 | #define NOTE_B6 1976 82 | #define NOTE_C7 2093 83 | #define NOTE_CS7 2217 84 | #define NOTE_D7 2349 85 | #define NOTE_DS7 2489 86 | #define NOTE_E7 2637 87 | #define NOTE_F7 2794 88 | #define NOTE_FS7 2960 89 | #define NOTE_G7 3136 90 | #define NOTE_GS7 3322 91 | #define NOTE_A7 3520 92 | #define NOTE_AS7 3729 93 | #define NOTE_B7 3951 94 | #define NOTE_C8 4186 95 | #define NOTE_CS8 4435 96 | #define NOTE_D8 4699 97 | #define NOTE_DS8 4978 98 | #define REST 0 99 | 100 | // change this to make the song slower or faster 101 | int tempo=114; 102 | 103 | // change this to whichever pin you want to use 104 | int buzzer = 11; 105 | 106 | // notes of the moledy followed by the duration. 107 | // a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on 108 | // !!negative numbers are used to represent dotted notes, 109 | // so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!! 110 | int melody[] = { 111 | 112 | 113 | NOTE_E4,4, NOTE_E4,4, NOTE_F4,4, NOTE_G4,4,//1 114 | NOTE_G4,4, NOTE_F4,4, NOTE_E4,4, NOTE_D4,4, 115 | NOTE_C4,4, NOTE_C4,4, NOTE_D4,4, NOTE_E4,4, 116 | NOTE_E4,-4, NOTE_D4,8, NOTE_D4,2, 117 | 118 | NOTE_E4,4, NOTE_E4,4, NOTE_F4,4, NOTE_G4,4,//4 119 | NOTE_G4,4, NOTE_F4,4, NOTE_E4,4, NOTE_D4,4, 120 | NOTE_C4,4, NOTE_C4,4, NOTE_D4,4, NOTE_E4,4, 121 | NOTE_D4,-4, NOTE_C4,8, NOTE_C4,2, 122 | 123 | NOTE_D4,4, NOTE_D4,4, NOTE_E4,4, NOTE_C4,4,//8 124 | NOTE_D4,4, NOTE_E4,8, NOTE_F4,8, NOTE_E4,4, NOTE_C4,4, 125 | NOTE_D4,4, NOTE_E4,8, NOTE_F4,8, NOTE_E4,4, NOTE_D4,4, 126 | NOTE_C4,4, NOTE_D4,4, NOTE_G3,2, 127 | 128 | NOTE_E4,4, NOTE_E4,4, NOTE_F4,4, NOTE_G4,4,//12 129 | NOTE_G4,4, NOTE_F4,4, NOTE_E4,4, NOTE_D4,4, 130 | NOTE_C4,4, NOTE_C4,4, NOTE_D4,4, NOTE_E4,4, 131 | NOTE_D4,-4, NOTE_C4,8, NOTE_C4,2 132 | 133 | }; 134 | 135 | // sizeof gives the number of bytes, each int value is composed of two bytes (16 bits) 136 | // there are two values per note (pitch and duration), so for each note there are four bytes 137 | int notes=sizeof(melody)/sizeof(melody[0])/2; 138 | 139 | // this calculates the duration of a whole note in ms (60s/tempo)*4 beats 140 | int wholenote = (60000 * 4) / tempo; 141 | 142 | int divider = 0, noteDuration = 0; 143 | 144 | void setup() { 145 | 146 | // iterate over the notes of the melody. 147 | // Remember, the array is twice the number of notes (notes + durations) 148 | for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) { 149 | 150 | // calculates the duration of each note 151 | divider = melody[thisNote + 1]; 152 | if (divider > 0) { 153 | // regular note, just proceed 154 | noteDuration = (wholenote) / divider; 155 | } else if (divider < 0) { 156 | // dotted notes are represented with negative durations!! 157 | noteDuration = (wholenote) / abs(divider); 158 | noteDuration *= 1.5; // increases the duration in half for dotted notes 159 | } 160 | 161 | // we only play the note for 90% of the duration, leaving 10% as a pause 162 | tone(buzzer, melody[thisNote], noteDuration*0.9); 163 | 164 | // Wait for the specief duration before playing the next note. 165 | delay(noteDuration); 166 | 167 | // stop the waveform generation before the next note. 168 | noTone(buzzer); 169 | } 170 | 171 | } 172 | 173 | void loop() { 174 | // if you want to repeat the song forever, 175 | // just paste the setup code here instead. 176 | } 177 | -------------------------------------------------------------------------------- /cantinaband/cantinaband.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Cantina band song from Star Wars 3 | Connect a piezo buzzer or speaker to pin 11 or select a new pin. 4 | More songs available at https://github.com/robsoncouto/arduino-songs 5 | 6 | Robson Couto, 2019 7 | */ 8 | 9 | #define NOTE_B0 31 10 | #define NOTE_C1 33 11 | #define NOTE_CS1 35 12 | #define NOTE_D1 37 13 | #define NOTE_DS1 39 14 | #define NOTE_E1 41 15 | #define NOTE_F1 44 16 | #define NOTE_FS1 46 17 | #define NOTE_G1 49 18 | #define NOTE_GS1 52 19 | #define NOTE_A1 55 20 | #define NOTE_AS1 58 21 | #define NOTE_B1 62 22 | #define NOTE_C2 65 23 | #define NOTE_CS2 69 24 | #define NOTE_D2 73 25 | #define NOTE_DS2 78 26 | #define NOTE_E2 82 27 | #define NOTE_F2 87 28 | #define NOTE_FS2 93 29 | #define NOTE_G2 98 30 | #define NOTE_GS2 104 31 | #define NOTE_A2 110 32 | #define NOTE_AS2 117 33 | #define NOTE_B2 123 34 | #define NOTE_C3 131 35 | #define NOTE_CS3 139 36 | #define NOTE_D3 147 37 | #define NOTE_DS3 156 38 | #define NOTE_E3 165 39 | #define NOTE_F3 175 40 | #define NOTE_FS3 185 41 | #define NOTE_G3 196 42 | #define NOTE_GS3 208 43 | #define NOTE_A3 220 44 | #define NOTE_AS3 233 45 | #define NOTE_B3 247 46 | #define NOTE_C4 262 47 | #define NOTE_CS4 277 48 | #define NOTE_D4 294 49 | #define NOTE_DS4 311 50 | #define NOTE_E4 330 51 | #define NOTE_F4 349 52 | #define NOTE_FS4 370 53 | #define NOTE_G4 392 54 | #define NOTE_GS4 415 55 | #define NOTE_A4 440 56 | #define NOTE_AS4 466 57 | #define NOTE_B4 494 58 | #define NOTE_C5 523 59 | #define NOTE_CS5 554 60 | #define NOTE_D5 587 61 | #define NOTE_DS5 622 62 | #define NOTE_E5 659 63 | #define NOTE_F5 698 64 | #define NOTE_FS5 740 65 | #define NOTE_G5 784 66 | #define NOTE_GS5 831 67 | #define NOTE_A5 880 68 | #define NOTE_AS5 932 69 | #define NOTE_B5 988 70 | #define NOTE_C6 1047 71 | #define NOTE_CS6 1109 72 | #define NOTE_D6 1175 73 | #define NOTE_DS6 1245 74 | #define NOTE_E6 1319 75 | #define NOTE_F6 1397 76 | #define NOTE_FS6 1480 77 | #define NOTE_G6 1568 78 | #define NOTE_GS6 1661 79 | #define NOTE_A6 1760 80 | #define NOTE_AS6 1865 81 | #define NOTE_B6 1976 82 | #define NOTE_C7 2093 83 | #define NOTE_CS7 2217 84 | #define NOTE_D7 2349 85 | #define NOTE_DS7 2489 86 | #define NOTE_E7 2637 87 | #define NOTE_F7 2794 88 | #define NOTE_FS7 2960 89 | #define NOTE_G7 3136 90 | #define NOTE_GS7 3322 91 | #define NOTE_A7 3520 92 | #define NOTE_AS7 3729 93 | #define NOTE_B7 3951 94 | #define NOTE_C8 4186 95 | #define NOTE_CS8 4435 96 | #define NOTE_D8 4699 97 | #define NOTE_DS8 4978 98 | #define REST 0 99 | 100 | 101 | // change this to make the song slower or faster 102 | int tempo = 140; 103 | 104 | // change this to whichever pin you want to use 105 | int buzzer = 11; 106 | 107 | // notes of the moledy followed by the duration. 108 | // a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on 109 | // !!negative numbers are used to represent dotted notes, 110 | // so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!! 111 | int melody[] = { 112 | 113 | // Cantina BAnd - Star wars 114 | // Score available at https://musescore.com/user/6795541/scores/1606876 115 | NOTE_B4,-4, NOTE_E5,-4, NOTE_B4,-4, NOTE_E5,-4, 116 | NOTE_B4,8, NOTE_E5,-4, NOTE_B4,8, REST,8, NOTE_AS4,8, NOTE_B4,8, 117 | NOTE_B4,8, NOTE_AS4,8, NOTE_B4,8, NOTE_A4,8, REST,8, NOTE_GS4,8, NOTE_A4,8, NOTE_G4,8, 118 | NOTE_G4,4, NOTE_E4,-2, 119 | NOTE_B4,-4, NOTE_E5,-4, NOTE_B4,-4, NOTE_E5,-4, 120 | NOTE_B4,8, NOTE_E5,-4, NOTE_B4,8, REST,8, NOTE_AS4,8, NOTE_B4,8, 121 | 122 | NOTE_A4,-4, NOTE_A4,-4, NOTE_GS4,8, NOTE_A4,-4, 123 | NOTE_D5,8, NOTE_C5,-4, NOTE_B4,-4, NOTE_A4,-4, 124 | NOTE_B4,-4, NOTE_E5,-4, NOTE_B4,-4, NOTE_E5,-4, 125 | NOTE_B4,8, NOTE_E5,-4, NOTE_B4,8, REST,8, NOTE_AS4,8, NOTE_B4,8, 126 | NOTE_D5,4, NOTE_D5,-4, NOTE_B4,8, NOTE_A4,-4, 127 | NOTE_G4,-4, NOTE_E4,-2, 128 | NOTE_E4, 2, NOTE_G4,2, 129 | NOTE_B4, 2, NOTE_D5,2, 130 | 131 | NOTE_F5, -4, NOTE_E5,-4, NOTE_AS4,8, NOTE_AS4,8, NOTE_B4,4, NOTE_G4,4, 132 | 133 | 134 | 135 | 136 | }; 137 | 138 | // sizeof gives the number of bytes, each int value is composed of two bytes (16 bits) 139 | // there are two values per note (pitch and duration), so for each note there are four bytes 140 | int notes = sizeof(melody) / sizeof(melody[0]) / 2; 141 | 142 | // this calculates the duration of a whole note in ms 143 | int wholenote = (60000 * 2) / tempo; 144 | 145 | int divider = 0, noteDuration = 0; 146 | 147 | void setup() { 148 | // iterate over the notes of the melody. 149 | // Remember, the array is twice the number of notes (notes + durations) 150 | for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) { 151 | 152 | // calculates the duration of each note 153 | divider = melody[thisNote + 1]; 154 | if (divider > 0) { 155 | // regular note, just proceed 156 | noteDuration = (wholenote) / divider; 157 | } else if (divider < 0) { 158 | // dotted notes are represented with negative durations!! 159 | noteDuration = (wholenote) / abs(divider); 160 | noteDuration *= 1.5; // increases the duration in half for dotted notes 161 | } 162 | 163 | // we only play the note for 90% of the duration, leaving 10% as a pause 164 | tone(buzzer, melody[thisNote], noteDuration*0.9); 165 | 166 | // Wait for the specief duration before playing the next note. 167 | delay(noteDuration); 168 | 169 | // stop the waveform generation before the next note. 170 | noTone(buzzer); 171 | } 172 | } 173 | 174 | void loop() { 175 | // no need to repeat the melody. 176 | } 177 | -------------------------------------------------------------------------------- /songofstorms/songofstorms.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Song of storms - Legend of Zelda 3 | Connect a piezo buzzer or speaker to pin 11 or select a new pin. 4 | More songs available at https://github.com/robsoncouto/arduino-songs 5 | 6 | Robson Couto, 2019 7 | */ 8 | 9 | #define NOTE_B0 31 10 | #define NOTE_C1 33 11 | #define NOTE_CS1 35 12 | #define NOTE_D1 37 13 | #define NOTE_DS1 39 14 | #define NOTE_E1 41 15 | #define NOTE_F1 44 16 | #define NOTE_FS1 46 17 | #define NOTE_G1 49 18 | #define NOTE_GS1 52 19 | #define NOTE_A1 55 20 | #define NOTE_AS1 58 21 | #define NOTE_B1 62 22 | #define NOTE_C2 65 23 | #define NOTE_CS2 69 24 | #define NOTE_D2 73 25 | #define NOTE_DS2 78 26 | #define NOTE_E2 82 27 | #define NOTE_F2 87 28 | #define NOTE_FS2 93 29 | #define NOTE_G2 98 30 | #define NOTE_GS2 104 31 | #define NOTE_A2 110 32 | #define NOTE_AS2 117 33 | #define NOTE_B2 123 34 | #define NOTE_C3 131 35 | #define NOTE_CS3 139 36 | #define NOTE_D3 147 37 | #define NOTE_DS3 156 38 | #define NOTE_E3 165 39 | #define NOTE_F3 175 40 | #define NOTE_FS3 185 41 | #define NOTE_G3 196 42 | #define NOTE_GS3 208 43 | #define NOTE_A3 220 44 | #define NOTE_AS3 233 45 | #define NOTE_B3 247 46 | #define NOTE_C4 262 47 | #define NOTE_CS4 277 48 | #define NOTE_D4 294 49 | #define NOTE_DS4 311 50 | #define NOTE_E4 330 51 | #define NOTE_F4 349 52 | #define NOTE_FS4 370 53 | #define NOTE_G4 392 54 | #define NOTE_GS4 415 55 | #define NOTE_A4 440 56 | #define NOTE_AS4 466 57 | #define NOTE_B4 494 58 | #define NOTE_C5 523 59 | #define NOTE_CS5 554 60 | #define NOTE_D5 587 61 | #define NOTE_DS5 622 62 | #define NOTE_E5 659 63 | #define NOTE_F5 698 64 | #define NOTE_FS5 740 65 | #define NOTE_G5 784 66 | #define NOTE_GS5 831 67 | #define NOTE_A5 880 68 | #define NOTE_AS5 932 69 | #define NOTE_B5 988 70 | #define NOTE_C6 1047 71 | #define NOTE_CS6 1109 72 | #define NOTE_D6 1175 73 | #define NOTE_DS6 1245 74 | #define NOTE_E6 1319 75 | #define NOTE_F6 1397 76 | #define NOTE_FS6 1480 77 | #define NOTE_G6 1568 78 | #define NOTE_GS6 1661 79 | #define NOTE_A6 1760 80 | #define NOTE_AS6 1865 81 | #define NOTE_B6 1976 82 | #define NOTE_C7 2093 83 | #define NOTE_CS7 2217 84 | #define NOTE_D7 2349 85 | #define NOTE_DS7 2489 86 | #define NOTE_E7 2637 87 | #define NOTE_F7 2794 88 | #define NOTE_FS7 2960 89 | #define NOTE_G7 3136 90 | #define NOTE_GS7 3322 91 | #define NOTE_A7 3520 92 | #define NOTE_AS7 3729 93 | #define NOTE_B7 3951 94 | #define NOTE_C8 4186 95 | #define NOTE_CS8 4435 96 | #define NOTE_D8 4699 97 | #define NOTE_DS8 4978 98 | #define REST 0 99 | 100 | 101 | // change this to make the song slower or faster 102 | int tempo = 108; 103 | 104 | // change this to whichever pin you want to use 105 | int buzzer = 11; 106 | 107 | // notes of the moledy followed by the duration. 108 | // a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on 109 | // !!negative numbers are used to represent dotted notes, 110 | // so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!! 111 | int melody[] = { 112 | 113 | // Song of storms - The Legend of Zelda Ocarina of Time. 114 | // Score available at https://musescore.com/user/4957541/scores/1545401 115 | 116 | NOTE_D4,4, NOTE_A4,4, NOTE_A4,4, 117 | REST,8, NOTE_E4,8, NOTE_B4,2, 118 | NOTE_F4,4, NOTE_C5,4, NOTE_C5,4, 119 | REST,8, NOTE_E4,8, NOTE_B4,2, 120 | NOTE_D4,4, NOTE_A4,4, NOTE_A4,4, 121 | REST,8, NOTE_E4,8, NOTE_B4,2, 122 | NOTE_F4,4, NOTE_C5,4, NOTE_C5,4, 123 | REST,8, NOTE_E4,8, NOTE_B4,2, 124 | NOTE_D4,8, NOTE_F4,8, NOTE_D5,2, 125 | 126 | NOTE_D4,8, NOTE_F4,8, NOTE_D5,2, 127 | NOTE_E5,-4, NOTE_F5,8, NOTE_E5,8, NOTE_E5,8, 128 | NOTE_E5,8, NOTE_C5,8, NOTE_A4,2, 129 | NOTE_A4,4, NOTE_D4,4, NOTE_F4,8, NOTE_G4,8, 130 | NOTE_A4,-2, 131 | NOTE_A4,4, NOTE_D4,4, NOTE_F4,8, NOTE_G4,8, 132 | NOTE_E4,-2, 133 | NOTE_D4,8, NOTE_F4,8, NOTE_D5,2, 134 | NOTE_D4,8, NOTE_F4,8, NOTE_D5,2, 135 | 136 | NOTE_E5,-4, NOTE_F5,8, NOTE_E5,8, NOTE_E5,8, 137 | NOTE_E5,8, NOTE_C5,8, NOTE_A4,2, 138 | NOTE_A4,4, NOTE_D4,4, NOTE_F4,8, NOTE_G4,8, 139 | NOTE_A4,2, NOTE_A4,4, 140 | NOTE_D4,1, 141 | }; 142 | 143 | // sizeof gives the number of bytes, each int value is composed of two bytes (16 bits) 144 | // there are two values per note (pitch and duration), so for each note there are four bytes 145 | int notes = sizeof(melody) / sizeof(melody[0]) / 2; 146 | 147 | // this calculates the duration of a whole note in ms 148 | int wholenote = (60000 * 4) / tempo; 149 | 150 | int divider = 0, noteDuration = 0; 151 | 152 | void setup() { 153 | // iterate over the notes of the melody. 154 | // Remember, the array is twice the number of notes (notes + durations) 155 | for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) { 156 | 157 | // calculates the duration of each note 158 | divider = melody[thisNote + 1]; 159 | if (divider > 0) { 160 | // regular note, just proceed 161 | noteDuration = (wholenote) / divider; 162 | } else if (divider < 0) { 163 | // dotted notes are represented with negative durations!! 164 | noteDuration = (wholenote) / abs(divider); 165 | noteDuration *= 1.5; // increases the duration in half for dotted notes 166 | } 167 | 168 | // we only play the note for 90% of the duration, leaving 10% as a pause 169 | tone(buzzer, melody[thisNote], noteDuration*0.9); 170 | 171 | // Wait for the specief duration before playing the next note. 172 | delay(noteDuration); 173 | 174 | // stop the waveform generation before the next note. 175 | noTone(buzzer); 176 | } 177 | } 178 | 179 | void loop() { 180 | // no need to repeat the melody. 181 | } 182 | -------------------------------------------------------------------------------- /starwars/starwars.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Star Wars theme 3 | Connect a piezo buzzer or speaker to pin 11 or select a new pin. 4 | More songs available at https://github.com/robsoncouto/arduino-songs 5 | 6 | Robson Couto, 2019 7 | */ 8 | 9 | #define NOTE_B0 31 10 | #define NOTE_C1 33 11 | #define NOTE_CS1 35 12 | #define NOTE_D1 37 13 | #define NOTE_DS1 39 14 | #define NOTE_E1 41 15 | #define NOTE_F1 44 16 | #define NOTE_FS1 46 17 | #define NOTE_G1 49 18 | #define NOTE_GS1 52 19 | #define NOTE_A1 55 20 | #define NOTE_AS1 58 21 | #define NOTE_B1 62 22 | #define NOTE_C2 65 23 | #define NOTE_CS2 69 24 | #define NOTE_D2 73 25 | #define NOTE_DS2 78 26 | #define NOTE_E2 82 27 | #define NOTE_F2 87 28 | #define NOTE_FS2 93 29 | #define NOTE_G2 98 30 | #define NOTE_GS2 104 31 | #define NOTE_A2 110 32 | #define NOTE_AS2 117 33 | #define NOTE_B2 123 34 | #define NOTE_C3 131 35 | #define NOTE_CS3 139 36 | #define NOTE_D3 147 37 | #define NOTE_DS3 156 38 | #define NOTE_E3 165 39 | #define NOTE_F3 175 40 | #define NOTE_FS3 185 41 | #define NOTE_G3 196 42 | #define NOTE_GS3 208 43 | #define NOTE_A3 220 44 | #define NOTE_AS3 233 45 | #define NOTE_B3 247 46 | #define NOTE_C4 262 47 | #define NOTE_CS4 277 48 | #define NOTE_D4 294 49 | #define NOTE_DS4 311 50 | #define NOTE_E4 330 51 | #define NOTE_F4 349 52 | #define NOTE_FS4 370 53 | #define NOTE_G4 392 54 | #define NOTE_GS4 415 55 | #define NOTE_A4 440 56 | #define NOTE_AS4 466 57 | #define NOTE_B4 494 58 | #define NOTE_C5 523 59 | #define NOTE_CS5 554 60 | #define NOTE_D5 587 61 | #define NOTE_DS5 622 62 | #define NOTE_E5 659 63 | #define NOTE_F5 698 64 | #define NOTE_FS5 740 65 | #define NOTE_G5 784 66 | #define NOTE_GS5 831 67 | #define NOTE_A5 880 68 | #define NOTE_AS5 932 69 | #define NOTE_B5 988 70 | #define NOTE_C6 1047 71 | #define NOTE_CS6 1109 72 | #define NOTE_D6 1175 73 | #define NOTE_DS6 1245 74 | #define NOTE_E6 1319 75 | #define NOTE_F6 1397 76 | #define NOTE_FS6 1480 77 | #define NOTE_G6 1568 78 | #define NOTE_GS6 1661 79 | #define NOTE_A6 1760 80 | #define NOTE_AS6 1865 81 | #define NOTE_B6 1976 82 | #define NOTE_C7 2093 83 | #define NOTE_CS7 2217 84 | #define NOTE_D7 2349 85 | #define NOTE_DS7 2489 86 | #define NOTE_E7 2637 87 | #define NOTE_F7 2794 88 | #define NOTE_FS7 2960 89 | #define NOTE_G7 3136 90 | #define NOTE_GS7 3322 91 | #define NOTE_A7 3520 92 | #define NOTE_AS7 3729 93 | #define NOTE_B7 3951 94 | #define NOTE_C8 4186 95 | #define NOTE_CS8 4435 96 | #define NOTE_D8 4699 97 | #define NOTE_DS8 4978 98 | #define REST 0 99 | 100 | 101 | // change this to make the song slower or faster 102 | int tempo = 108; 103 | 104 | // change this to whichever pin you want to use 105 | int buzzer = 11; 106 | 107 | // notes of the moledy followed by the duration. 108 | // a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on 109 | // !!negative numbers are used to represent dotted notes, 110 | // so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!! 111 | int melody[] = { 112 | 113 | // Star Wars Main Theme 114 | 115 | NOTE_AS4,8, NOTE_AS4,8, NOTE_AS4,8,//1 116 | NOTE_F5,2, NOTE_C6,2, 117 | NOTE_AS5,8, NOTE_A5,8, NOTE_G5,8, NOTE_F6,2, NOTE_C6,4, 118 | NOTE_AS5,8, NOTE_A5,8, NOTE_G5,8, NOTE_F6,2, NOTE_C6,4, 119 | NOTE_AS5,8, NOTE_A5,8, NOTE_AS5,8, NOTE_G5,2, NOTE_C5,8, NOTE_C5,8, NOTE_C5,8, 120 | NOTE_F5,2, NOTE_C6,2, 121 | NOTE_AS5,8, NOTE_A5,8, NOTE_G5,8, NOTE_F6,2, NOTE_C6,4, 122 | 123 | NOTE_AS5,8, NOTE_A5,8, NOTE_G5,8, NOTE_F6,2, NOTE_C6,4, //8 124 | NOTE_AS5,8, NOTE_A5,8, NOTE_AS5,8, NOTE_G5,2, NOTE_C5,-8, NOTE_C5,16, 125 | NOTE_D5,-4, NOTE_D5,8, NOTE_AS5,8, NOTE_A5,8, NOTE_G5,8, NOTE_F5,8, 126 | NOTE_F5,8, NOTE_G5,8, NOTE_A5,8, NOTE_G5,4, NOTE_D5,8, NOTE_E5,4,NOTE_C5,-8, NOTE_C5,16, 127 | NOTE_D5,-4, NOTE_D5,8, NOTE_AS5,8, NOTE_A5,8, NOTE_G5,8, NOTE_F5,8, 128 | 129 | NOTE_C6,-8, NOTE_G5,16, NOTE_G5,2, REST,8, NOTE_C5,8,//13 130 | NOTE_D5,-4, NOTE_D5,8, NOTE_AS5,8, NOTE_A5,8, NOTE_G5,8, NOTE_F5,8, 131 | NOTE_F5,8, NOTE_G5,8, NOTE_A5,8, NOTE_G5,4, NOTE_D5,8, NOTE_E5,4,NOTE_C6,-8, NOTE_C6,16, 132 | NOTE_F6,4, NOTE_DS6,8, NOTE_CS6,4, NOTE_C6,8, NOTE_AS5,4, NOTE_GS5,8, NOTE_G5,4, NOTE_F5,8, 133 | NOTE_C6,1 134 | 135 | }; 136 | 137 | // sizeof gives the number of bytes, each int value is composed of two bytes (16 bits) 138 | // there are two values per note (pitch and duration), so for each note there are four bytes 139 | int notes = sizeof(melody) / sizeof(melody[0]) / 2; 140 | 141 | // this calculates the duration of a whole note in ms 142 | int wholenote = (60000 * 4) / tempo; 143 | 144 | int divider = 0, noteDuration = 0; 145 | 146 | void setup() { 147 | // iterate over the notes of the melody. 148 | // Remember, the array is twice the number of notes (notes + durations) 149 | for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) { 150 | 151 | // calculates the duration of each note 152 | divider = melody[thisNote + 1]; 153 | if (divider > 0) { 154 | // regular note, just proceed 155 | noteDuration = (wholenote) / divider; 156 | } else if (divider < 0) { 157 | // dotted notes are represented with negative durations!! 158 | noteDuration = (wholenote) / abs(divider); 159 | noteDuration *= 1.5; // increases the duration in half for dotted notes 160 | } 161 | 162 | // we only play the note for 90% of the duration, leaving 10% as a pause 163 | tone(buzzer, melody[thisNote], noteDuration*0.9); 164 | 165 | // Wait for the specief duration before playing the next note. 166 | delay(noteDuration); 167 | 168 | // stop the waveform generation before the next note. 169 | noTone(buzzer); 170 | } 171 | } 172 | 173 | void loop() { 174 | // no need to repeat the melody. 175 | } 176 | -------------------------------------------------------------------------------- /harrypotter/harrypotter.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Hedwig's theme - Harry Potter 3 | Connect a piezo buzzer or speaker to pin 11 or select a new pin. 4 | More songs available at https://github.com/robsoncouto/arduino-songs 5 | 6 | Robson Couto, 2019 7 | */ 8 | 9 | #define NOTE_B0 31 10 | #define NOTE_C1 33 11 | #define NOTE_CS1 35 12 | #define NOTE_D1 37 13 | #define NOTE_DS1 39 14 | #define NOTE_E1 41 15 | #define NOTE_F1 44 16 | #define NOTE_FS1 46 17 | #define NOTE_G1 49 18 | #define NOTE_GS1 52 19 | #define NOTE_A1 55 20 | #define NOTE_AS1 58 21 | #define NOTE_B1 62 22 | #define NOTE_C2 65 23 | #define NOTE_CS2 69 24 | #define NOTE_D2 73 25 | #define NOTE_DS2 78 26 | #define NOTE_E2 82 27 | #define NOTE_F2 87 28 | #define NOTE_FS2 93 29 | #define NOTE_G2 98 30 | #define NOTE_GS2 104 31 | #define NOTE_A2 110 32 | #define NOTE_AS2 117 33 | #define NOTE_B2 123 34 | #define NOTE_C3 131 35 | #define NOTE_CS3 139 36 | #define NOTE_D3 147 37 | #define NOTE_DS3 156 38 | #define NOTE_E3 165 39 | #define NOTE_F3 175 40 | #define NOTE_FS3 185 41 | #define NOTE_G3 196 42 | #define NOTE_GS3 208 43 | #define NOTE_A3 220 44 | #define NOTE_AS3 233 45 | #define NOTE_B3 247 46 | #define NOTE_C4 262 47 | #define NOTE_CS4 277 48 | #define NOTE_D4 294 49 | #define NOTE_DS4 311 50 | #define NOTE_E4 330 51 | #define NOTE_F4 349 52 | #define NOTE_FS4 370 53 | #define NOTE_G4 392 54 | #define NOTE_GS4 415 55 | #define NOTE_A4 440 56 | #define NOTE_AS4 466 57 | #define NOTE_B4 494 58 | #define NOTE_C5 523 59 | #define NOTE_CS5 554 60 | #define NOTE_D5 587 61 | #define NOTE_DS5 622 62 | #define NOTE_E5 659 63 | #define NOTE_F5 698 64 | #define NOTE_FS5 740 65 | #define NOTE_G5 784 66 | #define NOTE_GS5 831 67 | #define NOTE_A5 880 68 | #define NOTE_AS5 932 69 | #define NOTE_B5 988 70 | #define NOTE_C6 1047 71 | #define NOTE_CS6 1109 72 | #define NOTE_D6 1175 73 | #define NOTE_DS6 1245 74 | #define NOTE_E6 1319 75 | #define NOTE_F6 1397 76 | #define NOTE_FS6 1480 77 | #define NOTE_G6 1568 78 | #define NOTE_GS6 1661 79 | #define NOTE_A6 1760 80 | #define NOTE_AS6 1865 81 | #define NOTE_B6 1976 82 | #define NOTE_C7 2093 83 | #define NOTE_CS7 2217 84 | #define NOTE_D7 2349 85 | #define NOTE_DS7 2489 86 | #define NOTE_E7 2637 87 | #define NOTE_F7 2794 88 | #define NOTE_FS7 2960 89 | #define NOTE_G7 3136 90 | #define NOTE_GS7 3322 91 | #define NOTE_A7 3520 92 | #define NOTE_AS7 3729 93 | #define NOTE_B7 3951 94 | #define NOTE_C8 4186 95 | #define NOTE_CS8 4435 96 | #define NOTE_D8 4699 97 | #define NOTE_DS8 4978 98 | #define REST 0 99 | 100 | // change this to make the song slower or faster 101 | int tempo = 144; 102 | 103 | // change this to whichever pin you want to use 104 | int buzzer = 11; 105 | 106 | // notes of the moledy followed by the duration. 107 | // a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on 108 | // !!negative numbers are used to represent dotted notes, 109 | // so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!! 110 | int melody[] = { 111 | 112 | 113 | // Hedwig's theme fromn the Harry Potter Movies 114 | // Socre from https://musescore.com/user/3811306/scores/4906610 115 | 116 | REST, 2, NOTE_D4, 4, 117 | NOTE_G4, -4, NOTE_AS4, 8, NOTE_A4, 4, 118 | NOTE_G4, 2, NOTE_D5, 4, 119 | NOTE_C5, -2, 120 | NOTE_A4, -2, 121 | NOTE_G4, -4, NOTE_AS4, 8, NOTE_A4, 4, 122 | NOTE_F4, 2, NOTE_GS4, 4, 123 | NOTE_D4, -1, 124 | NOTE_D4, 4, 125 | 126 | NOTE_G4, -4, NOTE_AS4, 8, NOTE_A4, 4, //10 127 | NOTE_G4, 2, NOTE_D5, 4, 128 | NOTE_F5, 2, NOTE_E5, 4, 129 | NOTE_DS5, 2, NOTE_B4, 4, 130 | NOTE_DS5, -4, NOTE_D5, 8, NOTE_CS5, 4, 131 | NOTE_CS4, 2, NOTE_B4, 4, 132 | NOTE_G4, -1, 133 | NOTE_AS4, 4, 134 | 135 | NOTE_D5, 2, NOTE_AS4, 4,//18 136 | NOTE_D5, 2, NOTE_AS4, 4, 137 | NOTE_DS5, 2, NOTE_D5, 4, 138 | NOTE_CS5, 2, NOTE_A4, 4, 139 | NOTE_AS4, -4, NOTE_D5, 8, NOTE_CS5, 4, 140 | NOTE_CS4, 2, NOTE_D4, 4, 141 | NOTE_D5, -1, 142 | REST,4, NOTE_AS4,4, 143 | 144 | NOTE_D5, 2, NOTE_AS4, 4,//26 145 | NOTE_D5, 2, NOTE_AS4, 4, 146 | NOTE_F5, 2, NOTE_E5, 4, 147 | NOTE_DS5, 2, NOTE_B4, 4, 148 | NOTE_DS5, -4, NOTE_D5, 8, NOTE_CS5, 4, 149 | NOTE_CS4, 2, NOTE_AS4, 4, 150 | NOTE_G4, -1, 151 | 152 | }; 153 | 154 | // sizeof gives the number of bytes, each int value is composed of two bytes (16 bits) 155 | // there are two values per note (pitch and duration), so for each note there are four bytes 156 | int notes = sizeof(melody) / sizeof(melody[0]) / 2; 157 | 158 | // this calculates the duration of a whole note in ms (60s/tempo)*4 beats 159 | int wholenote = (60000 * 4) / tempo; 160 | 161 | int divider = 0, noteDuration = 0; 162 | 163 | void setup() { 164 | // iterate over the notes of the melody. 165 | // Remember, the array is twice the number of notes (notes + durations) 166 | for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) { 167 | 168 | // calculates the duration of each note 169 | divider = melody[thisNote + 1]; 170 | if (divider > 0) { 171 | // regular note, just proceed 172 | noteDuration = (wholenote) / divider; 173 | } else if (divider < 0) { 174 | // dotted notes are represented with negative durations!! 175 | noteDuration = (wholenote) / abs(divider); 176 | noteDuration *= 1.5; // increases the duration in half for dotted notes 177 | } 178 | 179 | // we only play the note for 90% of the duration, leaving 10% as a pause 180 | tone(buzzer, melody[thisNote], noteDuration*0.9); 181 | 182 | // Wait for the specief duration before playing the next note. 183 | delay(noteDuration); 184 | 185 | // stop the waveform generation before the next note. 186 | noTone(buzzer); 187 | } 188 | } 189 | 190 | void loop() { 191 | // no need to repeat the melody. 192 | } 193 | -------------------------------------------------------------------------------- /asabranca/asabranca.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Asa branca 3 | Connect a piezo buzzer or speaker to pin 11 or select a new pin. 4 | More songs available at https://github.com/robsoncouto/arduino-songs 5 | 6 | Robson Couto, 2019 7 | */ 8 | #define NOTE_B0 31 9 | #define NOTE_C1 33 10 | #define NOTE_CS1 35 11 | #define NOTE_D1 37 12 | #define NOTE_DS1 39 13 | #define NOTE_E1 41 14 | #define NOTE_F1 44 15 | #define NOTE_FS1 46 16 | #define NOTE_G1 49 17 | #define NOTE_GS1 52 18 | #define NOTE_A1 55 19 | #define NOTE_AS1 58 20 | #define NOTE_B1 62 21 | #define NOTE_C2 65 22 | #define NOTE_CS2 69 23 | #define NOTE_D2 73 24 | #define NOTE_DS2 78 25 | #define NOTE_E2 82 26 | #define NOTE_F2 87 27 | #define NOTE_FS2 93 28 | #define NOTE_G2 98 29 | #define NOTE_GS2 104 30 | #define NOTE_A2 110 31 | #define NOTE_AS2 117 32 | #define NOTE_B2 123 33 | #define NOTE_C3 131 34 | #define NOTE_CS3 139 35 | #define NOTE_D3 147 36 | #define NOTE_DS3 156 37 | #define NOTE_E3 165 38 | #define NOTE_F3 175 39 | #define NOTE_FS3 185 40 | #define NOTE_G3 196 41 | #define NOTE_GS3 208 42 | #define NOTE_A3 220 43 | #define NOTE_AS3 233 44 | #define NOTE_B3 247 45 | #define NOTE_C4 262 46 | #define NOTE_CS4 277 47 | #define NOTE_D4 294 48 | #define NOTE_DS4 311 49 | #define NOTE_E4 330 50 | #define NOTE_F4 349 51 | #define NOTE_FS4 370 52 | #define NOTE_G4 392 53 | #define NOTE_GS4 415 54 | #define NOTE_A4 440 55 | #define NOTE_AS4 466 56 | #define NOTE_B4 494 57 | #define NOTE_C5 523 58 | #define NOTE_CS5 554 59 | #define NOTE_D5 587 60 | #define NOTE_DS5 622 61 | #define NOTE_E5 659 62 | #define NOTE_F5 698 63 | #define NOTE_FS5 740 64 | #define NOTE_G5 784 65 | #define NOTE_GS5 831 66 | #define NOTE_A5 880 67 | #define NOTE_AS5 932 68 | #define NOTE_B5 988 69 | #define NOTE_C6 1047 70 | #define NOTE_CS6 1109 71 | #define NOTE_D6 1175 72 | #define NOTE_DS6 1245 73 | #define NOTE_E6 1319 74 | #define NOTE_F6 1397 75 | #define NOTE_FS6 1480 76 | #define NOTE_G6 1568 77 | #define NOTE_GS6 1661 78 | #define NOTE_A6 1760 79 | #define NOTE_AS6 1865 80 | #define NOTE_B6 1976 81 | #define NOTE_C7 2093 82 | #define NOTE_CS7 2217 83 | #define NOTE_D7 2349 84 | #define NOTE_DS7 2489 85 | #define NOTE_E7 2637 86 | #define NOTE_F7 2794 87 | #define NOTE_FS7 2960 88 | #define NOTE_G7 3136 89 | #define NOTE_GS7 3322 90 | #define NOTE_A7 3520 91 | #define NOTE_AS7 3729 92 | #define NOTE_B7 3951 93 | #define NOTE_C8 4186 94 | #define NOTE_CS8 4435 95 | #define NOTE_D8 4699 96 | #define NOTE_DS8 4978 97 | #define REST 0 98 | 99 | 100 | // change this to make the song slower or faster 101 | int tempo = 120; 102 | 103 | // change this to whichever pin you want to use 104 | int buzzer = 11; 105 | 106 | // notes of the moledy followed by the duration. 107 | // a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on 108 | // !!negative numbers are used to represent dotted notes, 109 | // so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!! 110 | int melody[] = { 111 | 112 | // Asa branca - Luiz Gonzaga 113 | // Score available at https://musescore.com/user/190926/scores/181370 114 | 115 | NOTE_G4,8, NOTE_A4,8, NOTE_B4,4, NOTE_D5,4, NOTE_D5,4, NOTE_B4,4, 116 | NOTE_C5,4, NOTE_C5,2, NOTE_G4,8, NOTE_A4,8, 117 | NOTE_B4,4, NOTE_D5,4, NOTE_D5,4, NOTE_C5,4, 118 | 119 | NOTE_B4,2, REST,8, NOTE_G4,8, NOTE_G4,8, NOTE_A4,8, 120 | NOTE_B4,4, NOTE_D5,4, REST,8, NOTE_D5,8, NOTE_C5,8, NOTE_B4,8, 121 | NOTE_G4,4, NOTE_C5,4, REST,8, NOTE_C5,8, NOTE_B4,8, NOTE_A4,8, 122 | 123 | NOTE_A4,4, NOTE_B4,4, REST,8, NOTE_B4,8, NOTE_A4,8, NOTE_G4,8, 124 | NOTE_G4,2, REST,8, NOTE_G4,8, NOTE_G4,8, NOTE_A4,8, 125 | NOTE_B4,4, NOTE_D5,4, REST,8, NOTE_D5,8, NOTE_C5,8, NOTE_B4,8, 126 | 127 | NOTE_G4,4, NOTE_C5,4, REST,8, NOTE_C5,8, NOTE_B4,8, NOTE_A4,8, 128 | NOTE_A4,4, NOTE_B4,4, REST,8, NOTE_B4,8, NOTE_A4,8, NOTE_G4,8, 129 | NOTE_G4,4, NOTE_F5,8, NOTE_D5,8, NOTE_E5,8, NOTE_C5,8, NOTE_D5,8, NOTE_B4,8, 130 | 131 | NOTE_C5,8, NOTE_A4,8, NOTE_B4,8, NOTE_G4,8, NOTE_A4,8, NOTE_G4,8, NOTE_E4,8, NOTE_G4,8, 132 | NOTE_G4,4, NOTE_F5,8, NOTE_D5,8, NOTE_E5,8, NOTE_C5,8, NOTE_D5,8, NOTE_B4,8, 133 | NOTE_C5,8, NOTE_A4,8, NOTE_B4,8, NOTE_G4,8, NOTE_A4,8, NOTE_G4,8, NOTE_E4,8, NOTE_G4,8, 134 | NOTE_G4,-2, REST,4 135 | 136 | }; 137 | 138 | // sizeof gives the number of bytes, each int value is composed of two bytes (16 bits) 139 | // there are two values per note (pitch and duration), so for each note there are four bytes 140 | int notes = sizeof(melody) / sizeof(melody[0]) / 2; 141 | 142 | // this calculates the duration of a whole note in ms 143 | int wholenote = (60000 * 4) / tempo; 144 | 145 | int divider = 0, noteDuration = 0; 146 | 147 | void setup() { 148 | // iterate over the notes of the melody. 149 | // Remember, the array is twice the number of notes (notes + durations) 150 | for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) { 151 | 152 | // calculates the duration of each note 153 | divider = melody[thisNote + 1]; 154 | if (divider > 0) { 155 | // regular note, just proceed 156 | noteDuration = (wholenote) / divider; 157 | } else if (divider < 0) { 158 | // dotted notes are represented with negative durations!! 159 | noteDuration = (wholenote) / abs(divider); 160 | noteDuration *= 1.5; // increases the duration in half for dotted notes 161 | } 162 | 163 | // we only play the note for 90% of the duration, leaving 10% as a pause 164 | tone(buzzer, melody[thisNote], noteDuration * 0.9); 165 | 166 | // Wait for the specief duration before playing the next note. 167 | delay(noteDuration); 168 | 169 | // stop the waveform generation before the next note. 170 | noTone(buzzer); 171 | } 172 | } 173 | 174 | void loop() { 175 | // no need to repeat the melody. 176 | } 177 | -------------------------------------------------------------------------------- /takeonme/takeonme.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Take on me 3 | Connect a piezo buzzer or speaker to pin 11 or select a new pin. 4 | More songs available at https://github.com/robsoncouto/arduino-songs 5 | 6 | Robson Couto, 2019 7 | */ 8 | #define NOTE_B0 31 9 | #define NOTE_C1 33 10 | #define NOTE_CS1 35 11 | #define NOTE_D1 37 12 | #define NOTE_DS1 39 13 | #define NOTE_E1 41 14 | #define NOTE_F1 44 15 | #define NOTE_FS1 46 16 | #define NOTE_G1 49 17 | #define NOTE_GS1 52 18 | #define NOTE_A1 55 19 | #define NOTE_AS1 58 20 | #define NOTE_B1 62 21 | #define NOTE_C2 65 22 | #define NOTE_CS2 69 23 | #define NOTE_D2 73 24 | #define NOTE_DS2 78 25 | #define NOTE_E2 82 26 | #define NOTE_F2 87 27 | #define NOTE_FS2 93 28 | #define NOTE_G2 98 29 | #define NOTE_GS2 104 30 | #define NOTE_A2 110 31 | #define NOTE_AS2 117 32 | #define NOTE_B2 123 33 | #define NOTE_C3 131 34 | #define NOTE_CS3 139 35 | #define NOTE_D3 147 36 | #define NOTE_DS3 156 37 | #define NOTE_E3 165 38 | #define NOTE_F3 175 39 | #define NOTE_FS3 185 40 | #define NOTE_G3 196 41 | #define NOTE_GS3 208 42 | #define NOTE_A3 220 43 | #define NOTE_AS3 233 44 | #define NOTE_B3 247 45 | #define NOTE_C4 262 46 | #define NOTE_CS4 277 47 | #define NOTE_D4 294 48 | #define NOTE_DS4 311 49 | #define NOTE_E4 330 50 | #define NOTE_F4 349 51 | #define NOTE_FS4 370 52 | #define NOTE_G4 392 53 | #define NOTE_GS4 415 54 | #define NOTE_A4 440 55 | #define NOTE_AS4 466 56 | #define NOTE_B4 494 57 | #define NOTE_C5 523 58 | #define NOTE_CS5 554 59 | #define NOTE_D5 587 60 | #define NOTE_DS5 622 61 | #define NOTE_E5 659 62 | #define NOTE_F5 698 63 | #define NOTE_FS5 740 64 | #define NOTE_G5 784 65 | #define NOTE_GS5 831 66 | #define NOTE_A5 880 67 | #define NOTE_AS5 932 68 | #define NOTE_B5 988 69 | #define NOTE_C6 1047 70 | #define NOTE_CS6 1109 71 | #define NOTE_D6 1175 72 | #define NOTE_DS6 1245 73 | #define NOTE_E6 1319 74 | #define NOTE_F6 1397 75 | #define NOTE_FS6 1480 76 | #define NOTE_G6 1568 77 | #define NOTE_GS6 1661 78 | #define NOTE_A6 1760 79 | #define NOTE_AS6 1865 80 | #define NOTE_B6 1976 81 | #define NOTE_C7 2093 82 | #define NOTE_CS7 2217 83 | #define NOTE_D7 2349 84 | #define NOTE_DS7 2489 85 | #define NOTE_E7 2637 86 | #define NOTE_F7 2794 87 | #define NOTE_FS7 2960 88 | #define NOTE_G7 3136 89 | #define NOTE_GS7 3322 90 | #define NOTE_A7 3520 91 | #define NOTE_AS7 3729 92 | #define NOTE_B7 3951 93 | #define NOTE_C8 4186 94 | #define NOTE_CS8 4435 95 | #define NOTE_D8 4699 96 | #define NOTE_DS8 4978 97 | #define REST 0 98 | 99 | 100 | // change this to make the song slower or faster 101 | int tempo = 140; 102 | 103 | // change this to whichever pin you want to use 104 | int buzzer = 11; 105 | 106 | // notes of the moledy followed by the duration. 107 | // a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on 108 | // !!negative numbers are used to represent dotted notes, 109 | // so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!! 110 | int melody[] = { 111 | 112 | // Take on me, by A-ha 113 | // Score available at https://musescore.com/user/27103612/scores/4834399 114 | // Arranged by Edward Truong 115 | 116 | NOTE_FS5,8, NOTE_FS5,8,NOTE_D5,8, NOTE_B4,8, REST,8, NOTE_B4,8, REST,8, NOTE_E5,8, 117 | REST,8, NOTE_E5,8, REST,8, NOTE_E5,8, NOTE_GS5,8, NOTE_GS5,8, NOTE_A5,8, NOTE_B5,8, 118 | NOTE_A5,8, NOTE_A5,8, NOTE_A5,8, NOTE_E5,8, REST,8, NOTE_D5,8, REST,8, NOTE_FS5,8, 119 | REST,8, NOTE_FS5,8, REST,8, NOTE_FS5,8, NOTE_E5,8, NOTE_E5,8, NOTE_FS5,8, NOTE_E5,8, 120 | NOTE_FS5,8, NOTE_FS5,8,NOTE_D5,8, NOTE_B4,8, REST,8, NOTE_B4,8, REST,8, NOTE_E5,8, 121 | 122 | REST,8, NOTE_E5,8, REST,8, NOTE_E5,8, NOTE_GS5,8, NOTE_GS5,8, NOTE_A5,8, NOTE_B5,8, 123 | NOTE_A5,8, NOTE_A5,8, NOTE_A5,8, NOTE_E5,8, REST,8, NOTE_D5,8, REST,8, NOTE_FS5,8, 124 | REST,8, NOTE_FS5,8, REST,8, NOTE_FS5,8, NOTE_E5,8, NOTE_E5,8, NOTE_FS5,8, NOTE_E5,8, 125 | NOTE_FS5,8, NOTE_FS5,8,NOTE_D5,8, NOTE_B4,8, REST,8, NOTE_B4,8, REST,8, NOTE_E5,8, 126 | REST,8, NOTE_E5,8, REST,8, NOTE_E5,8, NOTE_GS5,8, NOTE_GS5,8, NOTE_A5,8, NOTE_B5,8, 127 | 128 | NOTE_A5,8, NOTE_A5,8, NOTE_A5,8, NOTE_E5,8, REST,8, NOTE_D5,8, REST,8, NOTE_FS5,8, 129 | REST,8, NOTE_FS5,8, REST,8, NOTE_FS5,8, NOTE_E5,8, NOTE_E5,8, NOTE_FS5,8, NOTE_E5,8, 130 | 131 | }; 132 | 133 | // sizeof gives the number of bytes, each int value is composed of two bytes (16 bits) 134 | // there are two values per note (pitch and duration), so for each note there are four bytes 135 | int notes = sizeof(melody) / sizeof(melody[0]) / 2; 136 | 137 | // this calculates the duration of a whole note in ms 138 | int wholenote = (60000 * 4) / tempo; 139 | 140 | int divider = 0, noteDuration = 0; 141 | 142 | void setup() { 143 | // iterate over the notes of the melody. 144 | // Remember, the array is twice the number of notes (notes + durations) 145 | for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) { 146 | 147 | // calculates the duration of each note 148 | divider = melody[thisNote + 1]; 149 | if (divider > 0) { 150 | // regular note, just proceed 151 | noteDuration = (wholenote) / divider; 152 | } else if (divider < 0) { 153 | // dotted notes are represented with negative durations!! 154 | noteDuration = (wholenote) / abs(divider); 155 | noteDuration *= 1.5; // increases the duration in half for dotted notes 156 | } 157 | 158 | // we only play the note for 90% of the duration, leaving 10% as a pause 159 | tone(buzzer, melody[thisNote], noteDuration * 0.9); 160 | 161 | // Wait for the specief duration before playing the next note. 162 | delay(noteDuration); 163 | 164 | // stop the waveform generation before the next note. 165 | noTone(buzzer); 166 | } 167 | } 168 | 169 | void loop() { 170 | // no need to repeat the melody. 171 | } 172 | -------------------------------------------------------------------------------- /pinkpanther/pinkpanther.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Pink Panther theme 3 | Connect a piezo buzzer or speaker to pin 11 or select a new pin. 4 | More songs available at https://github.com/robsoncouto/arduino-songs 5 | 6 | Robson Couto, 2019 7 | */ 8 | #define NOTE_B0 31 9 | #define NOTE_C1 33 10 | #define NOTE_CS1 35 11 | #define NOTE_D1 37 12 | #define NOTE_DS1 39 13 | #define NOTE_E1 41 14 | #define NOTE_F1 44 15 | #define NOTE_FS1 46 16 | #define NOTE_G1 49 17 | #define NOTE_GS1 52 18 | #define NOTE_A1 55 19 | #define NOTE_AS1 58 20 | #define NOTE_B1 62 21 | #define NOTE_C2 65 22 | #define NOTE_CS2 69 23 | #define NOTE_D2 73 24 | #define NOTE_DS2 78 25 | #define NOTE_E2 82 26 | #define NOTE_F2 87 27 | #define NOTE_FS2 93 28 | #define NOTE_G2 98 29 | #define NOTE_GS2 104 30 | #define NOTE_A2 110 31 | #define NOTE_AS2 117 32 | #define NOTE_B2 123 33 | #define NOTE_C3 131 34 | #define NOTE_CS3 139 35 | #define NOTE_D3 147 36 | #define NOTE_DS3 156 37 | #define NOTE_E3 165 38 | #define NOTE_F3 175 39 | #define NOTE_FS3 185 40 | #define NOTE_G3 196 41 | #define NOTE_GS3 208 42 | #define NOTE_A3 220 43 | #define NOTE_AS3 233 44 | #define NOTE_B3 247 45 | #define NOTE_C4 262 46 | #define NOTE_CS4 277 47 | #define NOTE_D4 294 48 | #define NOTE_DS4 311 49 | #define NOTE_E4 330 50 | #define NOTE_F4 349 51 | #define NOTE_FS4 370 52 | #define NOTE_G4 392 53 | #define NOTE_GS4 415 54 | #define NOTE_A4 440 55 | #define NOTE_AS4 466 56 | #define NOTE_B4 494 57 | #define NOTE_C5 523 58 | #define NOTE_CS5 554 59 | #define NOTE_D5 587 60 | #define NOTE_DS5 622 61 | #define NOTE_E5 659 62 | #define NOTE_F5 698 63 | #define NOTE_FS5 740 64 | #define NOTE_G5 784 65 | #define NOTE_GS5 831 66 | #define NOTE_A5 880 67 | #define NOTE_AS5 932 68 | #define NOTE_B5 988 69 | #define NOTE_C6 1047 70 | #define NOTE_CS6 1109 71 | #define NOTE_D6 1175 72 | #define NOTE_DS6 1245 73 | #define NOTE_E6 1319 74 | #define NOTE_F6 1397 75 | #define NOTE_FS6 1480 76 | #define NOTE_G6 1568 77 | #define NOTE_GS6 1661 78 | #define NOTE_A6 1760 79 | #define NOTE_AS6 1865 80 | #define NOTE_B6 1976 81 | #define NOTE_C7 2093 82 | #define NOTE_CS7 2217 83 | #define NOTE_D7 2349 84 | #define NOTE_DS7 2489 85 | #define NOTE_E7 2637 86 | #define NOTE_F7 2794 87 | #define NOTE_FS7 2960 88 | #define NOTE_G7 3136 89 | #define NOTE_GS7 3322 90 | #define NOTE_A7 3520 91 | #define NOTE_AS7 3729 92 | #define NOTE_B7 3951 93 | #define NOTE_C8 4186 94 | #define NOTE_CS8 4435 95 | #define NOTE_D8 4699 96 | #define NOTE_DS8 4978 97 | #define REST 0 98 | 99 | 100 | // change this to make the song slower or faster 101 | int tempo = 120; 102 | 103 | // change this to whichever pin you want to use 104 | int buzzer = 11; 105 | 106 | // notes of the moledy followed by the duration. 107 | // a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on 108 | // !!negative numbers are used to represent dotted notes, 109 | // so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!! 110 | int melody[] = { 111 | 112 | // Pink Panther theme 113 | // Score available at https://musescore.com/benedictsong/the-pink-panther 114 | // Theme by Masato Nakamura, arranged by Teddy Mason 115 | 116 | REST,2, REST,4, REST,8, NOTE_DS4,8, 117 | NOTE_E4,-4, REST,8, NOTE_FS4,8, NOTE_G4,-4, REST,8, NOTE_DS4,8, 118 | NOTE_E4,-8, NOTE_FS4,8, NOTE_G4,-8, NOTE_C5,8, NOTE_B4,-8, NOTE_E4,8, NOTE_G4,-8, NOTE_B4,8, 119 | NOTE_AS4,2, NOTE_A4,-16, NOTE_G4,-16, NOTE_E4,-16, NOTE_D4,-16, 120 | NOTE_E4,2, REST,4, REST,8, NOTE_DS4,4, 121 | 122 | NOTE_E4,-4, REST,8, NOTE_FS4,8, NOTE_G4,-4, REST,8, NOTE_DS4,8, 123 | NOTE_E4,-8, NOTE_FS4,8, NOTE_G4,-8, NOTE_C5,8, NOTE_B4,-8, NOTE_G4,8, NOTE_B4,-8, NOTE_E5,8, 124 | NOTE_DS5,1, 125 | NOTE_D5,2, REST,4, REST,8, NOTE_DS4,8, 126 | NOTE_E4,-4, REST,8, NOTE_FS4,8, NOTE_G4,-4, REST,8, NOTE_DS4,8, 127 | NOTE_E4,-8, NOTE_FS4,8, NOTE_G4,-8, NOTE_C5,8, NOTE_B4,-8, NOTE_E4,8, NOTE_G4,-8, NOTE_B4,8, 128 | 129 | NOTE_AS4,2, NOTE_A4,-16, NOTE_G4,-16, NOTE_E4,-16, NOTE_D4,-16, 130 | NOTE_E4,-4, REST,4, 131 | REST,4, NOTE_E5,-8, NOTE_D5,8, NOTE_B4,-8, NOTE_A4,8, NOTE_G4,-8, NOTE_E4,-8, 132 | NOTE_AS4,16, NOTE_A4,-8, NOTE_AS4,16, NOTE_A4,-8, NOTE_AS4,16, NOTE_A4,-8, NOTE_AS4,16, NOTE_A4,-8, 133 | NOTE_G4,-16, NOTE_E4,-16, NOTE_D4,-16, NOTE_E4,16, NOTE_E4,16, NOTE_E4,2, 134 | 135 | }; 136 | 137 | // sizeof gives the number of bytes, each int value is composed of two bytes (16 bits) 138 | // there are two values per note (pitch and duration), so for each note there are four bytes 139 | int notes = sizeof(melody) / sizeof(melody[0]) / 2; 140 | 141 | // this calculates the duration of a whole note in ms 142 | int wholenote = (60000 * 4) / tempo; 143 | 144 | int divider = 0, noteDuration = 0; 145 | 146 | void setup() { 147 | // iterate over the notes of the melody. 148 | // Remember, the array is twice the number of notes (notes + durations) 149 | for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) { 150 | 151 | // calculates the duration of each note 152 | divider = melody[thisNote + 1]; 153 | if (divider > 0) { 154 | // regular note, just proceed 155 | noteDuration = (wholenote) / divider; 156 | } else if (divider < 0) { 157 | // dotted notes are represented with negative durations!! 158 | noteDuration = (wholenote) / abs(divider); 159 | noteDuration *= 1.5; // increases the duration in half for dotted notes 160 | } 161 | 162 | // we only play the note for 90% of the duration, leaving 10% as a pause 163 | tone(buzzer, melody[thisNote], noteDuration * 0.9); 164 | 165 | // Wait for the specief duration before playing the next note. 166 | delay(noteDuration); 167 | 168 | // stop the waveform generation before the next note. 169 | noTone(buzzer); 170 | } 171 | } 172 | 173 | void loop() { 174 | // no need to repeat the melody. 175 | } 176 | -------------------------------------------------------------------------------- /imperialmarch/imperialmarch.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Imperial March - Star Wars 3 | Connect a piezo buzzer or speaker to pin 11 or select a new pin. 4 | More songs available at https://github.com/robsoncouto/arduino-songs 5 | 6 | Robson Couto, 2019 7 | */ 8 | 9 | #define NOTE_B0 31 10 | #define NOTE_C1 33 11 | #define NOTE_CS1 35 12 | #define NOTE_D1 37 13 | #define NOTE_DS1 39 14 | #define NOTE_E1 41 15 | #define NOTE_F1 44 16 | #define NOTE_FS1 46 17 | #define NOTE_G1 49 18 | #define NOTE_GS1 52 19 | #define NOTE_A1 55 20 | #define NOTE_AS1 58 21 | #define NOTE_B1 62 22 | #define NOTE_C2 65 23 | #define NOTE_CS2 69 24 | #define NOTE_D2 73 25 | #define NOTE_DS2 78 26 | #define NOTE_E2 82 27 | #define NOTE_F2 87 28 | #define NOTE_FS2 93 29 | #define NOTE_G2 98 30 | #define NOTE_GS2 104 31 | #define NOTE_A2 110 32 | #define NOTE_AS2 117 33 | #define NOTE_B2 123 34 | #define NOTE_C3 131 35 | #define NOTE_CS3 139 36 | #define NOTE_D3 147 37 | #define NOTE_DS3 156 38 | #define NOTE_E3 165 39 | #define NOTE_F3 175 40 | #define NOTE_FS3 185 41 | #define NOTE_G3 196 42 | #define NOTE_GS3 208 43 | #define NOTE_A3 220 44 | #define NOTE_AS3 233 45 | #define NOTE_B3 247 46 | #define NOTE_C4 262 47 | #define NOTE_CS4 277 48 | #define NOTE_D4 294 49 | #define NOTE_DS4 311 50 | #define NOTE_E4 330 51 | #define NOTE_F4 349 52 | #define NOTE_FS4 370 53 | #define NOTE_G4 392 54 | #define NOTE_GS4 415 55 | #define NOTE_A4 440 56 | #define NOTE_AS4 466 57 | #define NOTE_B4 494 58 | #define NOTE_C5 523 59 | #define NOTE_CS5 554 60 | #define NOTE_D5 587 61 | #define NOTE_DS5 622 62 | #define NOTE_E5 659 63 | #define NOTE_F5 698 64 | #define NOTE_FS5 740 65 | #define NOTE_G5 784 66 | #define NOTE_GS5 831 67 | #define NOTE_A5 880 68 | #define NOTE_AS5 932 69 | #define NOTE_B5 988 70 | #define NOTE_C6 1047 71 | #define NOTE_CS6 1109 72 | #define NOTE_D6 1175 73 | #define NOTE_DS6 1245 74 | #define NOTE_E6 1319 75 | #define NOTE_F6 1397 76 | #define NOTE_FS6 1480 77 | #define NOTE_G6 1568 78 | #define NOTE_GS6 1661 79 | #define NOTE_A6 1760 80 | #define NOTE_AS6 1865 81 | #define NOTE_B6 1976 82 | #define NOTE_C7 2093 83 | #define NOTE_CS7 2217 84 | #define NOTE_D7 2349 85 | #define NOTE_DS7 2489 86 | #define NOTE_E7 2637 87 | #define NOTE_F7 2794 88 | #define NOTE_FS7 2960 89 | #define NOTE_G7 3136 90 | #define NOTE_GS7 3322 91 | #define NOTE_A7 3520 92 | #define NOTE_AS7 3729 93 | #define NOTE_B7 3951 94 | #define NOTE_C8 4186 95 | #define NOTE_CS8 4435 96 | #define NOTE_D8 4699 97 | #define NOTE_DS8 4978 98 | #define REST 0 99 | 100 | 101 | // change this to make the song slower or faster 102 | int tempo = 120; 103 | 104 | // change this to whichever pin you want to use 105 | int buzzer = 11; 106 | 107 | // notes of the moledy followed by the duration. 108 | // a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on 109 | // !!negative numbers are used to represent dotted notes, 110 | // so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!! 111 | int melody[] = { 112 | 113 | // Dart Vader theme (Imperial March) - Star wars 114 | // Score available at https://musescore.com/user/202909/scores/1141521 115 | // The tenor saxophone part was used 116 | 117 | NOTE_A4,-4, NOTE_A4,-4, NOTE_A4,16, NOTE_A4,16, NOTE_A4,16, NOTE_A4,16, NOTE_F4,8, REST,8, 118 | NOTE_A4,-4, NOTE_A4,-4, NOTE_A4,16, NOTE_A4,16, NOTE_A4,16, NOTE_A4,16, NOTE_F4,8, REST,8, 119 | NOTE_A4,4, NOTE_A4,4, NOTE_A4,4, NOTE_F4,-8, NOTE_C5,16, 120 | 121 | NOTE_A4,4, NOTE_F4,-8, NOTE_C5,16, NOTE_A4,2,//4 122 | NOTE_E5,4, NOTE_E5,4, NOTE_E5,4, NOTE_F5,-8, NOTE_C5,16, 123 | NOTE_A4,4, NOTE_F4,-8, NOTE_C5,16, NOTE_A4,2, 124 | 125 | NOTE_A5,4, NOTE_A4,-8, NOTE_A4,16, NOTE_A5,4, NOTE_GS5,-8, NOTE_G5,16, //7 126 | NOTE_DS5,16, NOTE_D5,16, NOTE_DS5,8, REST,8, NOTE_A4,8, NOTE_DS5,4, NOTE_D5,-8, NOTE_CS5,16, 127 | 128 | NOTE_C5,16, NOTE_B4,16, NOTE_C5,16, REST,8, NOTE_F4,8, NOTE_GS4,4, NOTE_F4,-8, NOTE_A4,-16,//9 129 | NOTE_C5,4, NOTE_A4,-8, NOTE_C5,16, NOTE_E5,2, 130 | 131 | NOTE_A5,4, NOTE_A4,-8, NOTE_A4,16, NOTE_A5,4, NOTE_GS5,-8, NOTE_G5,16, //7 132 | NOTE_DS5,16, NOTE_D5,16, NOTE_DS5,8, REST,8, NOTE_A4,8, NOTE_DS5,4, NOTE_D5,-8, NOTE_CS5,16, 133 | 134 | NOTE_C5,16, NOTE_B4,16, NOTE_C5,16, REST,8, NOTE_F4,8, NOTE_GS4,4, NOTE_F4,-8, NOTE_A4,-16,//9 135 | NOTE_A4,4, NOTE_F4,-8, NOTE_C5,16, NOTE_A4,2, 136 | 137 | }; 138 | 139 | // sizeof gives the number of bytes, each int value is composed of two bytes (16 bits) 140 | // there are two values per note (pitch and duration), so for each note there are four bytes 141 | int notes = sizeof(melody) / sizeof(melody[0]) / 2; 142 | 143 | // this calculates the duration of a whole note in ms 144 | int wholenote = (60000 * 4) / tempo; 145 | 146 | int divider = 0, noteDuration = 0; 147 | 148 | void setup() { 149 | // iterate over the notes of the melody. 150 | // Remember, the array is twice the number of notes (notes + durations) 151 | for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) { 152 | 153 | // calculates the duration of each note 154 | divider = melody[thisNote + 1]; 155 | if (divider > 0) { 156 | // regular note, just proceed 157 | noteDuration = (wholenote) / divider; 158 | } else if (divider < 0) { 159 | // dotted notes are represented with negative durations!! 160 | noteDuration = (wholenote) / abs(divider); 161 | noteDuration *= 1.5; // increases the duration in half for dotted notes 162 | } 163 | 164 | // we only play the note for 90% of the duration, leaving 10% as a pause 165 | tone(buzzer, melody[thisNote], noteDuration*0.9); 166 | 167 | // Wait for the specief duration before playing the next note. 168 | delay(noteDuration); 169 | 170 | // stop the waveform generation before the next note. 171 | noTone(buzzer); 172 | } 173 | } 174 | 175 | void loop() { 176 | // no need to repeat the melody. 177 | } 178 | -------------------------------------------------------------------------------- /tetris/tetris.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Tetris theme - (Korobeiniki) 3 | Connect a piezo buzzer or speaker to pin 11 or select a new pin. 4 | More songs available at https://github.com/robsoncouto/arduino-songs 5 | 6 | Robson Couto, 2019 7 | */ 8 | 9 | #define NOTE_B0 31 10 | #define NOTE_C1 33 11 | #define NOTE_CS1 35 12 | #define NOTE_D1 37 13 | #define NOTE_DS1 39 14 | #define NOTE_E1 41 15 | #define NOTE_F1 44 16 | #define NOTE_FS1 46 17 | #define NOTE_G1 49 18 | #define NOTE_GS1 52 19 | #define NOTE_A1 55 20 | #define NOTE_AS1 58 21 | #define NOTE_B1 62 22 | #define NOTE_C2 65 23 | #define NOTE_CS2 69 24 | #define NOTE_D2 73 25 | #define NOTE_DS2 78 26 | #define NOTE_E2 82 27 | #define NOTE_F2 87 28 | #define NOTE_FS2 93 29 | #define NOTE_G2 98 30 | #define NOTE_GS2 104 31 | #define NOTE_A2 110 32 | #define NOTE_AS2 117 33 | #define NOTE_B2 123 34 | #define NOTE_C3 131 35 | #define NOTE_CS3 139 36 | #define NOTE_D3 147 37 | #define NOTE_DS3 156 38 | #define NOTE_E3 165 39 | #define NOTE_F3 175 40 | #define NOTE_FS3 185 41 | #define NOTE_G3 196 42 | #define NOTE_GS3 208 43 | #define NOTE_A3 220 44 | #define NOTE_AS3 233 45 | #define NOTE_B3 247 46 | #define NOTE_C4 262 47 | #define NOTE_CS4 277 48 | #define NOTE_D4 294 49 | #define NOTE_DS4 311 50 | #define NOTE_E4 330 51 | #define NOTE_F4 349 52 | #define NOTE_FS4 370 53 | #define NOTE_G4 392 54 | #define NOTE_GS4 415 55 | #define NOTE_A4 440 56 | #define NOTE_AS4 466 57 | #define NOTE_B4 494 58 | #define NOTE_C5 523 59 | #define NOTE_CS5 554 60 | #define NOTE_D5 587 61 | #define NOTE_DS5 622 62 | #define NOTE_E5 659 63 | #define NOTE_F5 698 64 | #define NOTE_FS5 740 65 | #define NOTE_G5 784 66 | #define NOTE_GS5 831 67 | #define NOTE_A5 880 68 | #define NOTE_AS5 932 69 | #define NOTE_B5 988 70 | #define NOTE_C6 1047 71 | #define NOTE_CS6 1109 72 | #define NOTE_D6 1175 73 | #define NOTE_DS6 1245 74 | #define NOTE_E6 1319 75 | #define NOTE_F6 1397 76 | #define NOTE_FS6 1480 77 | #define NOTE_G6 1568 78 | #define NOTE_GS6 1661 79 | #define NOTE_A6 1760 80 | #define NOTE_AS6 1865 81 | #define NOTE_B6 1976 82 | #define NOTE_C7 2093 83 | #define NOTE_CS7 2217 84 | #define NOTE_D7 2349 85 | #define NOTE_DS7 2489 86 | #define NOTE_E7 2637 87 | #define NOTE_F7 2794 88 | #define NOTE_FS7 2960 89 | #define NOTE_G7 3136 90 | #define NOTE_GS7 3322 91 | #define NOTE_A7 3520 92 | #define NOTE_AS7 3729 93 | #define NOTE_B7 3951 94 | #define NOTE_C8 4186 95 | #define NOTE_CS8 4435 96 | #define NOTE_D8 4699 97 | #define NOTE_DS8 4978 98 | #define REST 0 99 | 100 | // change this to make the song slower or faster 101 | int tempo=144; 102 | 103 | // change this to whichever pin you want to use 104 | int buzzer = 11; 105 | 106 | // notes of the moledy followed by the duration. 107 | // a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on 108 | // !!negative numbers are used to represent dotted notes, 109 | // so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!! 110 | int melody[] = { 111 | 112 | //Based on the arrangement at https://www.flutetunes.com/tunes.php?id=192 113 | 114 | NOTE_E5, 4, NOTE_B4,8, NOTE_C5,8, NOTE_D5,4, NOTE_C5,8, NOTE_B4,8, 115 | NOTE_A4, 4, NOTE_A4,8, NOTE_C5,8, NOTE_E5,4, NOTE_D5,8, NOTE_C5,8, 116 | NOTE_B4, -4, NOTE_C5,8, NOTE_D5,4, NOTE_E5,4, 117 | NOTE_C5, 4, NOTE_A4,4, NOTE_A4,4, REST,4, 118 | 119 | REST,8, NOTE_D5, 4, NOTE_F5,8, NOTE_A5,4, NOTE_G5,8, NOTE_F5,8, 120 | NOTE_E5, -4, NOTE_C5,8, NOTE_E5,4, NOTE_D5,8, NOTE_C5,8, 121 | NOTE_B4, 4, NOTE_B4,8, NOTE_C5,8, NOTE_D5,4, NOTE_E5,4, 122 | NOTE_C5, 4, NOTE_A4,4, NOTE_A4,4, REST, 4, 123 | 124 | NOTE_E5,2, NOTE_C5,2, 125 | NOTE_D5,2, NOTE_B4,2, 126 | NOTE_C5,2, NOTE_A4,2, 127 | NOTE_B4,1, 128 | 129 | NOTE_E5,2, NOTE_C5,2, 130 | NOTE_D5,2, NOTE_B4,2, 131 | NOTE_C5,4, NOTE_E5,4, NOTE_A5,2, 132 | NOTE_GS5,1, 133 | 134 | NOTE_E5, 4, NOTE_B4,8, NOTE_C5,8, NOTE_D5,4, NOTE_C5,8, NOTE_B4,8, 135 | NOTE_A4, 4, NOTE_A4,8, NOTE_C5,8, NOTE_E5,4, NOTE_D5,8, NOTE_C5,8, 136 | NOTE_B4, -4, NOTE_C5,8, NOTE_D5,4, NOTE_E5,4, 137 | NOTE_C5, 4, NOTE_A4,4, NOTE_A4,4, REST,4, 138 | 139 | REST,8, NOTE_D5, 4, NOTE_F5,8, NOTE_A5,4, NOTE_G5,8, NOTE_F5,8, 140 | REST,8, NOTE_E5, 4, NOTE_C5,8, NOTE_E5,4, NOTE_D5,8, NOTE_C5,8, 141 | REST,8, NOTE_B4, 4, NOTE_C5,8, NOTE_D5,4, NOTE_E5,4, 142 | REST,8, NOTE_C5, 4, NOTE_A4,8, NOTE_A4,4, REST, 4, 143 | 144 | }; 145 | 146 | // sizeof gives the number of bytes, each int value is composed of two bytes (16 bits) 147 | // there are two values per note (pitch and duration), so for each note there are four bytes 148 | int notes=sizeof(melody)/sizeof(melody[0])/2; 149 | 150 | // this calculates the duration of a whole note in ms (60s/tempo)*4 beats 151 | int wholenote = (60000 * 4) / tempo; 152 | 153 | int divider = 0, noteDuration = 0; 154 | 155 | void setup() { 156 | // iterate over the notes of the melody. 157 | // Remember, the array is twice the number of notes (notes + durations) 158 | for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) { 159 | 160 | // calculates the duration of each note 161 | divider = melody[thisNote + 1]; 162 | if (divider > 0) { 163 | // regular note, just proceed 164 | noteDuration = (wholenote) / divider; 165 | } else if (divider < 0) { 166 | // dotted notes are represented with negative durations!! 167 | noteDuration = (wholenote) / abs(divider); 168 | noteDuration *= 1.5; // increases the duration in half for dotted notes 169 | } 170 | 171 | // we only play the note for 90% of the duration, leaving 10% as a pause 172 | tone(buzzer, melody[thisNote], noteDuration*0.9); 173 | 174 | // Wait for the specief duration before playing the next note. 175 | delay(noteDuration); 176 | 177 | // stop the waveform generation before the next note. 178 | noTone(buzzer); 179 | } 180 | } 181 | 182 | void loop() { 183 | // no need to repeat the melody. 184 | } 185 | -------------------------------------------------------------------------------- /zeldatheme/zeldatheme.ino: -------------------------------------------------------------------------------- 1 | /* 2 | The legend of Zelda theme 3 | Connect a piezo buzzer or speaker to pin 11 or select a new pin. 4 | More songs available at https://github.com/robsoncouto/arduino-songs 5 | 6 | Robson Couto, 2019 7 | */ 8 | 9 | #define NOTE_B0 31 10 | #define NOTE_C1 33 11 | #define NOTE_CS1 35 12 | #define NOTE_D1 37 13 | #define NOTE_DS1 39 14 | #define NOTE_E1 41 15 | #define NOTE_F1 44 16 | #define NOTE_FS1 46 17 | #define NOTE_G1 49 18 | #define NOTE_GS1 52 19 | #define NOTE_A1 55 20 | #define NOTE_AS1 58 21 | #define NOTE_B1 62 22 | #define NOTE_C2 65 23 | #define NOTE_CS2 69 24 | #define NOTE_D2 73 25 | #define NOTE_DS2 78 26 | #define NOTE_E2 82 27 | #define NOTE_F2 87 28 | #define NOTE_FS2 93 29 | #define NOTE_G2 98 30 | #define NOTE_GS2 104 31 | #define NOTE_A2 110 32 | #define NOTE_AS2 117 33 | #define NOTE_B2 123 34 | #define NOTE_C3 131 35 | #define NOTE_CS3 139 36 | #define NOTE_D3 147 37 | #define NOTE_DS3 156 38 | #define NOTE_E3 165 39 | #define NOTE_F3 175 40 | #define NOTE_FS3 185 41 | #define NOTE_G3 196 42 | #define NOTE_GS3 208 43 | #define NOTE_A3 220 44 | #define NOTE_AS3 233 45 | #define NOTE_B3 247 46 | #define NOTE_C4 262 47 | #define NOTE_CS4 277 48 | #define NOTE_D4 294 49 | #define NOTE_DS4 311 50 | #define NOTE_E4 330 51 | #define NOTE_F4 349 52 | #define NOTE_FS4 370 53 | #define NOTE_G4 392 54 | #define NOTE_GS4 415 55 | #define NOTE_A4 440 56 | #define NOTE_AS4 466 57 | #define NOTE_B4 494 58 | #define NOTE_C5 523 59 | #define NOTE_CS5 554 60 | #define NOTE_D5 587 61 | #define NOTE_DS5 622 62 | #define NOTE_E5 659 63 | #define NOTE_F5 698 64 | #define NOTE_FS5 740 65 | #define NOTE_G5 784 66 | #define NOTE_GS5 831 67 | #define NOTE_A5 880 68 | #define NOTE_AS5 932 69 | #define NOTE_B5 988 70 | #define NOTE_C6 1047 71 | #define NOTE_CS6 1109 72 | #define NOTE_D6 1175 73 | #define NOTE_DS6 1245 74 | #define NOTE_E6 1319 75 | #define NOTE_F6 1397 76 | #define NOTE_FS6 1480 77 | #define NOTE_G6 1568 78 | #define NOTE_GS6 1661 79 | #define NOTE_A6 1760 80 | #define NOTE_AS6 1865 81 | #define NOTE_B6 1976 82 | #define NOTE_C7 2093 83 | #define NOTE_CS7 2217 84 | #define NOTE_D7 2349 85 | #define NOTE_DS7 2489 86 | #define NOTE_E7 2637 87 | #define NOTE_F7 2794 88 | #define NOTE_FS7 2960 89 | #define NOTE_G7 3136 90 | #define NOTE_GS7 3322 91 | #define NOTE_A7 3520 92 | #define NOTE_AS7 3729 93 | #define NOTE_B7 3951 94 | #define NOTE_C8 4186 95 | #define NOTE_CS8 4435 96 | #define NOTE_D8 4699 97 | #define NOTE_DS8 4978 98 | #define REST 0 99 | 100 | int tempo=88; 101 | 102 | // change this to whichever pin you want to use 103 | int buzzer = 11; 104 | 105 | // notes of the moledy followed by the duration. 106 | // a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on 107 | // !!negative numbers are used to represent dotted notes, 108 | // so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!! 109 | int melody[] = { 110 | 111 | //Based on the arrangement at https://www.flutetunes.com/tunes.php?id=169 112 | 113 | NOTE_AS4,-2, NOTE_F4,8, NOTE_F4,8, NOTE_AS4,8,//1 114 | NOTE_GS4,16, NOTE_FS4,16, NOTE_GS4,-2, 115 | NOTE_AS4,-2, NOTE_FS4,8, NOTE_FS4,8, NOTE_AS4,8, 116 | NOTE_A4,16, NOTE_G4,16, NOTE_A4,-2, 117 | REST,1, 118 | 119 | NOTE_AS4,4, NOTE_F4,-4, NOTE_AS4,8, NOTE_AS4,16, NOTE_C5,16, NOTE_D5,16, NOTE_DS5,16,//7 120 | NOTE_F5,2, NOTE_F5,8, NOTE_F5,8, NOTE_F5,8, NOTE_FS5,16, NOTE_GS5,16, 121 | NOTE_AS5,-2, NOTE_AS5,8, NOTE_AS5,8, NOTE_GS5,8, NOTE_FS5,16, 122 | NOTE_GS5,-8, NOTE_FS5,16, NOTE_F5,2, NOTE_F5,4, 123 | 124 | NOTE_DS5,-8, NOTE_F5,16, NOTE_FS5,2, NOTE_F5,8, NOTE_DS5,8, //11 125 | NOTE_CS5,-8, NOTE_DS5,16, NOTE_F5,2, NOTE_DS5,8, NOTE_CS5,8, 126 | NOTE_C5,-8, NOTE_D5,16, NOTE_E5,2, NOTE_G5,8, 127 | NOTE_F5,16, NOTE_F4,16, NOTE_F4,16, NOTE_F4,16,NOTE_F4,16,NOTE_F4,16,NOTE_F4,16,NOTE_F4,16,NOTE_F4,8, NOTE_F4,16,NOTE_F4,8, 128 | 129 | NOTE_AS4,4, NOTE_F4,-4, NOTE_AS4,8, NOTE_AS4,16, NOTE_C5,16, NOTE_D5,16, NOTE_DS5,16,//15 130 | NOTE_F5,2, NOTE_F5,8, NOTE_F5,8, NOTE_F5,8, NOTE_FS5,16, NOTE_GS5,16, 131 | NOTE_AS5,-2, NOTE_CS6,4, 132 | NOTE_C6,4, NOTE_A5,2, NOTE_F5,4, 133 | NOTE_FS5,-2, NOTE_AS5,4, 134 | NOTE_A5,4, NOTE_F5,2, NOTE_F5,4, 135 | 136 | NOTE_FS5,-2, NOTE_AS5,4, 137 | NOTE_A5,4, NOTE_F5,2, NOTE_D5,4, 138 | NOTE_DS5,-2, NOTE_FS5,4, 139 | NOTE_F5,4, NOTE_CS5,2, NOTE_AS4,4, 140 | NOTE_C5,-8, NOTE_D5,16, NOTE_E5,2, NOTE_G5,8, 141 | NOTE_F5,16, NOTE_F4,16, NOTE_F4,16, NOTE_F4,16,NOTE_F4,16,NOTE_F4,16,NOTE_F4,16,NOTE_F4,16,NOTE_F4,8, NOTE_F4,16,NOTE_F4,8 142 | 143 | }; 144 | 145 | // sizeof gives the number of bytes, each int value is composed of two bytes (16 bits) 146 | // there are two values per note (pitch and duration), so for each note there are four bytes 147 | int notes=sizeof(melody)/sizeof(melody[0])/2; 148 | 149 | // this calculates the duration of a whole note in ms (60s/tempo)*4 beats 150 | int wholenote = (60000 * 4) / tempo; 151 | 152 | int divider = 0, noteDuration = 0; 153 | 154 | void setup() { 155 | // iterate over the notes of the melody. 156 | // Remember, the array is twice the number of notes (notes + durations) 157 | for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) { 158 | 159 | // calculates the duration of each note 160 | divider = melody[thisNote + 1]; 161 | if (divider > 0) { 162 | // regular note, just proceed 163 | noteDuration = (wholenote) / divider; 164 | } else if (divider < 0) { 165 | // dotted notes are represented with negative durations!! 166 | noteDuration = (wholenote) / abs(divider); 167 | noteDuration *= 1.5; // increases the duration in half for dotted notes 168 | } 169 | 170 | // we only play the note for 90% of the duration, leaving 10% as a pause 171 | tone(buzzer, melody[thisNote], noteDuration*0.9); 172 | 173 | // Wait for the specief duration before playing the next note. 174 | delay(noteDuration); 175 | 176 | // stop the waveform generation before the next note. 177 | noTone(buzzer); 178 | } 179 | 180 | } 181 | 182 | void loop() { 183 | // no need to repeat the melody. 184 | } 185 | -------------------------------------------------------------------------------- /cannonind/cannonind.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Pachelbel's Canon 3 | Connect a piezo buzzer or speaker to pin 11 or select a new pin. 4 | More songs available at https://github.com/robsoncouto/arduino-songs 5 | 6 | Robson Couto, 2019 7 | */ 8 | 9 | #define NOTE_B0 31 10 | #define NOTE_C1 33 11 | #define NOTE_CS1 35 12 | #define NOTE_D1 37 13 | #define NOTE_DS1 39 14 | #define NOTE_E1 41 15 | #define NOTE_F1 44 16 | #define NOTE_FS1 46 17 | #define NOTE_G1 49 18 | #define NOTE_GS1 52 19 | #define NOTE_A1 55 20 | #define NOTE_AS1 58 21 | #define NOTE_B1 62 22 | #define NOTE_C2 65 23 | #define NOTE_CS2 69 24 | #define NOTE_D2 73 25 | #define NOTE_DS2 78 26 | #define NOTE_E2 82 27 | #define NOTE_F2 87 28 | #define NOTE_FS2 93 29 | #define NOTE_G2 98 30 | #define NOTE_GS2 104 31 | #define NOTE_A2 110 32 | #define NOTE_AS2 117 33 | #define NOTE_B2 123 34 | #define NOTE_C3 131 35 | #define NOTE_CS3 139 36 | #define NOTE_D3 147 37 | #define NOTE_DS3 156 38 | #define NOTE_E3 165 39 | #define NOTE_F3 175 40 | #define NOTE_FS3 185 41 | #define NOTE_G3 196 42 | #define NOTE_GS3 208 43 | #define NOTE_A3 220 44 | #define NOTE_AS3 233 45 | #define NOTE_B3 247 46 | #define NOTE_C4 262 47 | #define NOTE_CS4 277 48 | #define NOTE_D4 294 49 | #define NOTE_DS4 311 50 | #define NOTE_E4 330 51 | #define NOTE_F4 349 52 | #define NOTE_FS4 370 53 | #define NOTE_G4 392 54 | #define NOTE_GS4 415 55 | #define NOTE_A4 440 56 | #define NOTE_AS4 466 57 | #define NOTE_B4 494 58 | #define NOTE_C5 523 59 | #define NOTE_CS5 554 60 | #define NOTE_D5 587 61 | #define NOTE_DS5 622 62 | #define NOTE_E5 659 63 | #define NOTE_F5 698 64 | #define NOTE_FS5 740 65 | #define NOTE_G5 784 66 | #define NOTE_GS5 831 67 | #define NOTE_A5 880 68 | #define NOTE_AS5 932 69 | #define NOTE_B5 988 70 | #define NOTE_C6 1047 71 | #define NOTE_CS6 1109 72 | #define NOTE_D6 1175 73 | #define NOTE_DS6 1245 74 | #define NOTE_E6 1319 75 | #define NOTE_F6 1397 76 | #define NOTE_FS6 1480 77 | #define NOTE_G6 1568 78 | #define NOTE_GS6 1661 79 | #define NOTE_A6 1760 80 | #define NOTE_AS6 1865 81 | #define NOTE_B6 1976 82 | #define NOTE_C7 2093 83 | #define NOTE_CS7 2217 84 | #define NOTE_D7 2349 85 | #define NOTE_DS7 2489 86 | #define NOTE_E7 2637 87 | #define NOTE_F7 2794 88 | #define NOTE_FS7 2960 89 | #define NOTE_G7 3136 90 | #define NOTE_GS7 3322 91 | #define NOTE_A7 3520 92 | #define NOTE_AS7 3729 93 | #define NOTE_B7 3951 94 | #define NOTE_C8 4186 95 | #define NOTE_CS8 4435 96 | #define NOTE_D8 4699 97 | #define NOTE_DS8 4978 98 | #define REST 0 99 | 100 | 101 | // change this to make the song slower or faster 102 | int tempo = 100; 103 | 104 | // change this to whichever pin you want to use 105 | int buzzer = 11; 106 | 107 | // notes of the moledy followed by the duration. 108 | // a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on 109 | // !!negative numbers are used to represent dotted notes, 110 | // so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!! 111 | int melody[] = { 112 | 113 | // Cannon in D - Pachelbel 114 | // Score available at https://musescore.com/user/4710311/scores/1975521 115 | // C F 116 | NOTE_FS4,2, NOTE_E4,2, 117 | NOTE_D4,2, NOTE_CS4,2, 118 | NOTE_B3,2, NOTE_A3,2, 119 | NOTE_B3,2, NOTE_CS4,2, 120 | NOTE_FS4,2, NOTE_E4,2, 121 | NOTE_D4,2, NOTE_CS4,2, 122 | NOTE_B3,2, NOTE_A3,2, 123 | NOTE_B3,2, NOTE_CS4,2, 124 | NOTE_D4,2, NOTE_CS4,2, 125 | NOTE_B3,2, NOTE_A3,2, 126 | NOTE_G3,2, NOTE_FS3,2, 127 | NOTE_G3,2, NOTE_A3,2, 128 | 129 | NOTE_D4,4, NOTE_FS4,8, NOTE_G4,8, NOTE_A4,4, NOTE_FS4,8, NOTE_G4,8, 130 | NOTE_A4,4, NOTE_B3,8, NOTE_CS4,8, NOTE_D4,8, NOTE_E4,8, NOTE_FS4,8, NOTE_G4,8, 131 | NOTE_FS4,4, NOTE_D4,8, NOTE_E4,8, NOTE_FS4,4, NOTE_FS3,8, NOTE_G3,8, 132 | NOTE_A3,8, NOTE_G3,8, NOTE_FS3,8, NOTE_G3,8, NOTE_A3,2, 133 | NOTE_G3,4, NOTE_B3,8, NOTE_A3,8, NOTE_G3,4, NOTE_FS3,8, NOTE_E3,8, 134 | NOTE_FS3,4, NOTE_D3,8, NOTE_E3,8, NOTE_FS3,8, NOTE_G3,8, NOTE_A3,8, NOTE_B3,8, 135 | 136 | NOTE_G3,4, NOTE_B3,8, NOTE_A3,8, NOTE_B3,4, NOTE_CS4,8, NOTE_D4,8, 137 | NOTE_A3,8, NOTE_B3,8, NOTE_CS4,8, NOTE_D4,8, NOTE_E4,8, NOTE_FS4,8, NOTE_G4,8, NOTE_A4,2, 138 | NOTE_A4,4, NOTE_FS4,8, NOTE_G4,8, NOTE_A4,4, 139 | NOTE_FS4,8, NOTE_G4,8, NOTE_A4,8, NOTE_A3,8, NOTE_B3,8, NOTE_CS4,8, 140 | NOTE_D4,8, NOTE_E4,8, NOTE_FS4,8, NOTE_G4,8, NOTE_FS4,4, NOTE_D4,8, NOTE_E4,8, 141 | NOTE_FS4,8, NOTE_CS4,8, NOTE_A3,8, NOTE_A3,8, 142 | 143 | NOTE_CS4,4, NOTE_B3,4, NOTE_D4,8, NOTE_CS4,8, NOTE_B3,4, 144 | NOTE_A3,8, NOTE_G3,8, NOTE_A3,4, NOTE_D3,8, NOTE_E3,8, NOTE_FS3,8, NOTE_G3,8, 145 | NOTE_A3,8, NOTE_B3,4, NOTE_G3,4, NOTE_B3,8, NOTE_A3,8, NOTE_B3,4, 146 | NOTE_CS4,8, NOTE_D4,8, NOTE_A3,8, NOTE_B3,8, NOTE_CS4,8, NOTE_D4,8, NOTE_E4,8, 147 | NOTE_FS4,8, NOTE_G4,8, NOTE_A4,2, 148 | 149 | 150 | }; 151 | 152 | // sizeof gives the number of bytes, each int value is composed of two bytes (16 bits) 153 | // there are two values per note (pitch and duration), so for each note there are four bytes 154 | int notes = sizeof(melody) / sizeof(melody[0]) / 2; 155 | 156 | // this calculates the duration of a whole note in ms 157 | int wholenote = (60000 * 4) / tempo; 158 | 159 | int divider = 0, noteDuration = 0; 160 | 161 | void setup() { 162 | // iterate over the notes of the melody. 163 | // Remember, the array is twice the number of notes (notes + durations) 164 | for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) { 165 | 166 | // calculates the duration of each note 167 | divider = melody[thisNote + 1]; 168 | if (divider > 0) { 169 | // regular note, just proceed 170 | noteDuration = (wholenote) / divider; 171 | } else if (divider < 0) { 172 | // dotted notes are represented with negative durations!! 173 | noteDuration = (wholenote) / abs(divider); 174 | noteDuration *= 1.5; // increases the duration in half for dotted notes 175 | } 176 | 177 | // we only play the note for 90% of the duration, leaving 10% as a pause 178 | tone(buzzer, melody[thisNote], noteDuration * 0.9); 179 | 180 | // Wait for the specief duration before playing the next note. 181 | delay(noteDuration); 182 | 183 | // stop the waveform generation before the next note. 184 | noTone(buzzer); 185 | } 186 | } 187 | 188 | void loop() { 189 | // no need to repeat the melody. 190 | } 191 | -------------------------------------------------------------------------------- /thegodfather/thegodfather.ino: -------------------------------------------------------------------------------- 1 | /* 2 | The Godfather 3 | Connect a piezo buzzer or speaker to pin 11 or select a new pin. 4 | More songs available at https://github.com/robsoncouto/arduino-songs 5 | 6 | Robson Couto, 2019 7 | */ 8 | #define NOTE_B0 31 9 | #define NOTE_C1 33 10 | #define NOTE_CS1 35 11 | #define NOTE_D1 37 12 | #define NOTE_DS1 39 13 | #define NOTE_E1 41 14 | #define NOTE_F1 44 15 | #define NOTE_FS1 46 16 | #define NOTE_G1 49 17 | #define NOTE_GS1 52 18 | #define NOTE_A1 55 19 | #define NOTE_AS1 58 20 | #define NOTE_B1 62 21 | #define NOTE_C2 65 22 | #define NOTE_CS2 69 23 | #define NOTE_D2 73 24 | #define NOTE_DS2 78 25 | #define NOTE_E2 82 26 | #define NOTE_F2 87 27 | #define NOTE_FS2 93 28 | #define NOTE_G2 98 29 | #define NOTE_GS2 104 30 | #define NOTE_A2 110 31 | #define NOTE_AS2 117 32 | #define NOTE_B2 123 33 | #define NOTE_C3 131 34 | #define NOTE_CS3 139 35 | #define NOTE_D3 147 36 | #define NOTE_DS3 156 37 | #define NOTE_E3 165 38 | #define NOTE_F3 175 39 | #define NOTE_FS3 185 40 | #define NOTE_G3 196 41 | #define NOTE_GS3 208 42 | #define NOTE_A3 220 43 | #define NOTE_AS3 233 44 | #define NOTE_B3 247 45 | #define NOTE_C4 262 46 | #define NOTE_CS4 277 47 | #define NOTE_D4 294 48 | #define NOTE_DS4 311 49 | #define NOTE_E4 330 50 | #define NOTE_F4 349 51 | #define NOTE_FS4 370 52 | #define NOTE_G4 392 53 | #define NOTE_GS4 415 54 | #define NOTE_A4 440 55 | #define NOTE_AS4 466 56 | #define NOTE_B4 494 57 | #define NOTE_C5 523 58 | #define NOTE_CS5 554 59 | #define NOTE_D5 587 60 | #define NOTE_DS5 622 61 | #define NOTE_E5 659 62 | #define NOTE_F5 698 63 | #define NOTE_FS5 740 64 | #define NOTE_G5 784 65 | #define NOTE_GS5 831 66 | #define NOTE_A5 880 67 | #define NOTE_AS5 932 68 | #define NOTE_B5 988 69 | #define NOTE_C6 1047 70 | #define NOTE_CS6 1109 71 | #define NOTE_D6 1175 72 | #define NOTE_DS6 1245 73 | #define NOTE_E6 1319 74 | #define NOTE_F6 1397 75 | #define NOTE_FS6 1480 76 | #define NOTE_G6 1568 77 | #define NOTE_GS6 1661 78 | #define NOTE_A6 1760 79 | #define NOTE_AS6 1865 80 | #define NOTE_B6 1976 81 | #define NOTE_C7 2093 82 | #define NOTE_CS7 2217 83 | #define NOTE_D7 2349 84 | #define NOTE_DS7 2489 85 | #define NOTE_E7 2637 86 | #define NOTE_F7 2794 87 | #define NOTE_FS7 2960 88 | #define NOTE_G7 3136 89 | #define NOTE_GS7 3322 90 | #define NOTE_A7 3520 91 | #define NOTE_AS7 3729 92 | #define NOTE_B7 3951 93 | #define NOTE_C8 4186 94 | #define NOTE_CS8 4435 95 | #define NOTE_D8 4699 96 | #define NOTE_DS8 4978 97 | #define REST 0 98 | 99 | 100 | // change this to make the song slower or faster 101 | int tempo = 80; 102 | 103 | // change this to whichever pin you want to use 104 | int buzzer = 11; 105 | 106 | // notes of the moledy followed by the duration. 107 | // a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on 108 | // !!negative numbers are used to represent dotted notes, 109 | // so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!! 110 | int melody[] = { 111 | 112 | // The Godfather theme 113 | // Score available at https://musescore.com/user/35463/scores/55160 114 | 115 | REST, 4, REST, 8, REST, 8, REST, 8, NOTE_E4, 8, NOTE_A4, 8, NOTE_C5, 8, //1 116 | NOTE_B4, 8, NOTE_A4, 8, NOTE_C5, 8, NOTE_A4, 8, NOTE_B4, 8, NOTE_A4, 8, NOTE_F4, 8, NOTE_G4, 8, 117 | NOTE_E4, 2, NOTE_E4, 8, NOTE_A4, 8, NOTE_C5, 8, 118 | NOTE_B4, 8, NOTE_A4, 8, NOTE_C5, 8, NOTE_A4, 8, NOTE_C5, 8, NOTE_A4, 8, NOTE_E4, 8, NOTE_DS4, 8, 119 | 120 | NOTE_D4, 2, NOTE_D4, 8, NOTE_F4, 8, NOTE_GS4, 8, //5 121 | NOTE_B4, 2, NOTE_D4, 8, NOTE_F4, 8, NOTE_GS4, 8, 122 | NOTE_A4, 2, NOTE_C4, 8, NOTE_C4, 8, NOTE_G4, 8, 123 | NOTE_F4, 8, NOTE_E4, 8, NOTE_G4, 8, NOTE_F4, 8, NOTE_F4, 8, NOTE_E4, 8, NOTE_E4, 8, NOTE_GS4, 8, 124 | 125 | NOTE_A4, 2, REST,8, NOTE_A4, 8, NOTE_A4, 8, NOTE_GS4, 8, //9 126 | NOTE_G4, 2, NOTE_B4, 8, NOTE_A4, 8, NOTE_F4, 8, 127 | NOTE_E4, 2, NOTE_E4, 8, NOTE_G4, 8, NOTE_E4, 8, 128 | NOTE_D4, 2, NOTE_D4, 8, NOTE_D4, 8, NOTE_F4, 8, NOTE_DS4, 8, 129 | 130 | NOTE_E4, 2, REST, 8, NOTE_E4, 8, NOTE_A4, 8, NOTE_C5, 8, //13 131 | 132 | //repeats from 2 133 | NOTE_B4, 8, NOTE_A4, 8, NOTE_C5, 8, NOTE_A4, 8, NOTE_B4, 8, NOTE_A4, 8, NOTE_F4, 8, NOTE_G4, 8, //2 134 | NOTE_E4, 2, NOTE_E4, 8, NOTE_A4, 8, NOTE_C5, 8, 135 | NOTE_B4, 8, NOTE_A4, 8, NOTE_C5, 8, NOTE_A4, 8, NOTE_C5, 8, NOTE_A4, 8, NOTE_E4, 8, NOTE_DS4, 8, 136 | 137 | NOTE_D4, 2, NOTE_D4, 8, NOTE_F4, 8, NOTE_GS4, 8, //5 138 | NOTE_B4, 2, NOTE_D4, 8, NOTE_F4, 8, NOTE_GS4, 8, 139 | NOTE_A4, 2, NOTE_C4, 8, NOTE_C4, 8, NOTE_G4, 8, 140 | NOTE_F4, 8, NOTE_E4, 8, NOTE_G4, 8, NOTE_F4, 8, NOTE_F4, 8, NOTE_E4, 8, NOTE_E4, 8, NOTE_GS4, 8, 141 | 142 | NOTE_A4, 2, REST,8, NOTE_A4, 8, NOTE_A4, 8, NOTE_GS4, 8, //9 143 | NOTE_G4, 2, NOTE_B4, 8, NOTE_A4, 8, NOTE_F4, 8, 144 | NOTE_E4, 2, NOTE_E4, 8, NOTE_G4, 8, NOTE_E4, 8, 145 | NOTE_D4, 2, NOTE_D4, 8, NOTE_D4, 8, NOTE_F4, 8, NOTE_DS4, 8, 146 | 147 | NOTE_E4, 2 //13 148 | }; 149 | 150 | // sizeof gives the number of bytes, each int value is composed of two bytes (16 bits) 151 | // there are two values per note (pitch and duration), so for each note there are four bytes 152 | int notes = sizeof(melody) / sizeof(melody[0]) / 2; 153 | 154 | // this calculates the duration of a whole note in ms 155 | int wholenote = (60000 * 4) / tempo; 156 | 157 | int divider = 0, noteDuration = 0; 158 | 159 | void setup() { 160 | // iterate over the notes of the melody. 161 | // Remember, the array is twice the number of notes (notes + durations) 162 | for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) { 163 | 164 | // calculates the duration of each note 165 | divider = melody[thisNote + 1]; 166 | if (divider > 0) { 167 | // regular note, just proceed 168 | noteDuration = (wholenote) / divider; 169 | } else if (divider < 0) { 170 | // dotted notes are represented with negative durations!! 171 | noteDuration = (wholenote) / abs(divider); 172 | noteDuration *= 1.5; // increases the duration in half for dotted notes 173 | } 174 | 175 | // we only play the note for 90% of the duration, leaving 10% as a pause 176 | tone(buzzer, melody[thisNote], noteDuration * 0.9); 177 | 178 | // Wait for the specief duration before playing the next note. 179 | delay(noteDuration); 180 | 181 | // stop the waveform generation before the next note. 182 | noTone(buzzer); 183 | } 184 | } 185 | 186 | void loop() { 187 | // no need to repeat the melody. 188 | } 189 | -------------------------------------------------------------------------------- /gameofthrones/gameofthrones.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Game of Thrones 3 | Connect a piezo buzzer or speaker to pin 11 or select a new pin. 4 | More songs available at https://github.com/robsoncouto/arduino-songs 5 | 6 | Robson Couto, 2019 7 | */ 8 | #define NOTE_B0 31 9 | #define NOTE_C1 33 10 | #define NOTE_CS1 35 11 | #define NOTE_D1 37 12 | #define NOTE_DS1 39 13 | #define NOTE_E1 41 14 | #define NOTE_F1 44 15 | #define NOTE_FS1 46 16 | #define NOTE_G1 49 17 | #define NOTE_GS1 52 18 | #define NOTE_A1 55 19 | #define NOTE_AS1 58 20 | #define NOTE_B1 62 21 | #define NOTE_C2 65 22 | #define NOTE_CS2 69 23 | #define NOTE_D2 73 24 | #define NOTE_DS2 78 25 | #define NOTE_E2 82 26 | #define NOTE_F2 87 27 | #define NOTE_FS2 93 28 | #define NOTE_G2 98 29 | #define NOTE_GS2 104 30 | #define NOTE_A2 110 31 | #define NOTE_AS2 117 32 | #define NOTE_B2 123 33 | #define NOTE_C3 131 34 | #define NOTE_CS3 139 35 | #define NOTE_D3 147 36 | #define NOTE_DS3 156 37 | #define NOTE_E3 165 38 | #define NOTE_F3 175 39 | #define NOTE_FS3 185 40 | #define NOTE_G3 196 41 | #define NOTE_GS3 208 42 | #define NOTE_A3 220 43 | #define NOTE_AS3 233 44 | #define NOTE_B3 247 45 | #define NOTE_C4 262 46 | #define NOTE_CS4 277 47 | #define NOTE_D4 294 48 | #define NOTE_DS4 311 49 | #define NOTE_E4 330 50 | #define NOTE_F4 349 51 | #define NOTE_FS4 370 52 | #define NOTE_G4 392 53 | #define NOTE_GS4 415 54 | #define NOTE_A4 440 55 | #define NOTE_AS4 466 56 | #define NOTE_B4 494 57 | #define NOTE_C5 523 58 | #define NOTE_CS5 554 59 | #define NOTE_D5 587 60 | #define NOTE_DS5 622 61 | #define NOTE_E5 659 62 | #define NOTE_F5 698 63 | #define NOTE_FS5 740 64 | #define NOTE_G5 784 65 | #define NOTE_GS5 831 66 | #define NOTE_A5 880 67 | #define NOTE_AS5 932 68 | #define NOTE_B5 988 69 | #define NOTE_C6 1047 70 | #define NOTE_CS6 1109 71 | #define NOTE_D6 1175 72 | #define NOTE_DS6 1245 73 | #define NOTE_E6 1319 74 | #define NOTE_F6 1397 75 | #define NOTE_FS6 1480 76 | #define NOTE_G6 1568 77 | #define NOTE_GS6 1661 78 | #define NOTE_A6 1760 79 | #define NOTE_AS6 1865 80 | #define NOTE_B6 1976 81 | #define NOTE_C7 2093 82 | #define NOTE_CS7 2217 83 | #define NOTE_D7 2349 84 | #define NOTE_DS7 2489 85 | #define NOTE_E7 2637 86 | #define NOTE_F7 2794 87 | #define NOTE_FS7 2960 88 | #define NOTE_G7 3136 89 | #define NOTE_GS7 3322 90 | #define NOTE_A7 3520 91 | #define NOTE_AS7 3729 92 | #define NOTE_B7 3951 93 | #define NOTE_C8 4186 94 | #define NOTE_CS8 4435 95 | #define NOTE_D8 4699 96 | #define NOTE_DS8 4978 97 | #define REST 0 98 | 99 | 100 | // change this to make the song slower or faster 101 | int tempo = 85; 102 | 103 | // change this to whichever pin you want to use 104 | int buzzer = 11; 105 | 106 | // notes of the moledy followed by the duration. 107 | // a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on 108 | // !!negative numbers are used to represent dotted notes, 109 | // so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!! 110 | int melody[] = { 111 | 112 | // Game of Thrones 113 | // Score available at https://musescore.com/user/8407786/scores/2156716 114 | 115 | NOTE_G4,8, NOTE_C4,8, NOTE_DS4,16, NOTE_F4,16, NOTE_G4,8, NOTE_C4,8, NOTE_DS4,16, NOTE_F4,16, //1 116 | NOTE_G4,8, NOTE_C4,8, NOTE_DS4,16, NOTE_F4,16, NOTE_G4,8, NOTE_C4,8, NOTE_DS4,16, NOTE_F4,16, 117 | NOTE_G4,8, NOTE_C4,8, NOTE_E4,16, NOTE_F4,16, NOTE_G4,8, NOTE_C4,8, NOTE_E4,16, NOTE_F4,16, 118 | NOTE_G4,8, NOTE_C4,8, NOTE_E4,16, NOTE_F4,16, NOTE_G4,8, NOTE_C4,8, NOTE_E4,16, NOTE_F4,16, 119 | NOTE_G4,-4, NOTE_C4,-4,//5 120 | 121 | NOTE_DS4,16, NOTE_F4,16, NOTE_G4,4, NOTE_C4,4, NOTE_DS4,16, NOTE_F4,16, //6 122 | NOTE_D4,-1, //7 and 8 123 | NOTE_F4,-4, NOTE_AS3,-4, 124 | NOTE_DS4,16, NOTE_D4,16, NOTE_F4,4, NOTE_AS3,-4, 125 | NOTE_DS4,16, NOTE_D4,16, NOTE_C4,-1, //11 and 12 126 | 127 | //repeats from 5 128 | NOTE_G4,-4, NOTE_C4,-4,//5 129 | 130 | NOTE_DS4,16, NOTE_F4,16, NOTE_G4,4, NOTE_C4,4, NOTE_DS4,16, NOTE_F4,16, //6 131 | NOTE_D4,-1, //7 and 8 132 | NOTE_F4,-4, NOTE_AS3,-4, 133 | NOTE_DS4,16, NOTE_D4,16, NOTE_F4,4, NOTE_AS3,-4, 134 | NOTE_DS4,16, NOTE_D4,16, NOTE_C4,-1, //11 and 12 135 | NOTE_G4,-4, NOTE_C4,-4, 136 | NOTE_DS4,16, NOTE_F4,16, NOTE_G4,4, NOTE_C4,4, NOTE_DS4,16, NOTE_F4,16, 137 | 138 | NOTE_D4,-2,//15 139 | NOTE_F4,-4, NOTE_AS3,-4, 140 | NOTE_D4,-8, NOTE_DS4,-8, NOTE_D4,-8, NOTE_AS3,-8, 141 | NOTE_C4,-1, 142 | NOTE_C5,-2, 143 | NOTE_AS4,-2, 144 | NOTE_C4,-2, 145 | NOTE_G4,-2, 146 | NOTE_DS4,-2, 147 | NOTE_DS4,-4, NOTE_F4,-4, 148 | NOTE_G4,-1, 149 | 150 | NOTE_C5,-2,//28 151 | NOTE_AS4,-2, 152 | NOTE_C4,-2, 153 | NOTE_G4,-2, 154 | NOTE_DS4,-2, 155 | NOTE_DS4,-4, NOTE_D4,-4, 156 | NOTE_C5,8, NOTE_G4,8, NOTE_GS4,16, NOTE_AS4,16, NOTE_C5,8, NOTE_G4,8, NOTE_GS4,16, NOTE_AS4,16, 157 | NOTE_C5,8, NOTE_G4,8, NOTE_GS4,16, NOTE_AS4,16, NOTE_C5,8, NOTE_G4,8, NOTE_GS4,16, NOTE_AS4,16, 158 | 159 | REST,4, NOTE_GS5,16, NOTE_AS5,16, NOTE_C6,8, NOTE_G5,8, NOTE_GS5,16, NOTE_AS5,16, 160 | NOTE_C6,8, NOTE_G5,16, NOTE_GS5,16, NOTE_AS5,16, NOTE_C6,8, NOTE_G5,8, NOTE_GS5,16, NOTE_AS5,16, 161 | }; 162 | 163 | // sizeof gives the number of bytes, each int value is composed of two bytes (16 bits) 164 | // there are two values per note (pitch and duration), so for each note there are four bytes 165 | int notes = sizeof(melody) / sizeof(melody[0]) / 2; 166 | 167 | // this calculates the duration of a whole note in ms 168 | int wholenote = (60000 * 4) / tempo; 169 | 170 | int divider = 0, noteDuration = 0; 171 | 172 | void setup() { 173 | // iterate over the notes of the melody. 174 | // Remember, the array is twice the number of notes (notes + durations) 175 | for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) { 176 | 177 | // calculates the duration of each note 178 | divider = melody[thisNote + 1]; 179 | if (divider > 0) { 180 | // regular note, just proceed 181 | noteDuration = (wholenote) / divider; 182 | } else if (divider < 0) { 183 | // dotted notes are represented with negative durations!! 184 | noteDuration = (wholenote) / abs(divider); 185 | noteDuration *= 1.5; // increases the duration in half for dotted notes 186 | } 187 | 188 | // we only play the note for 90% of the duration, leaving 10% as a pause 189 | tone(buzzer, melody[thisNote], noteDuration * 0.9); 190 | 191 | // Wait for the specief duration before playing the next note. 192 | delay(noteDuration); 193 | 194 | // stop the waveform generation before the next note. 195 | noTone(buzzer); 196 | } 197 | } 198 | 199 | void loop() { 200 | // no need to repeat the melody. 201 | } 202 | -------------------------------------------------------------------------------- /greensleeves/greensleeves.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Greensleves - Traditional English folk song 3 | Connect a piezo buzzer or speaker to pin 11 or select a new pin. 4 | More songs available at https://github.com/robsoncouto/arduino-songs 5 | 6 | Robson Couto, 2019 7 | */ 8 | #define NOTE_B0 31 9 | #define NOTE_C1 33 10 | #define NOTE_CS1 35 11 | #define NOTE_D1 37 12 | #define NOTE_DS1 39 13 | #define NOTE_E1 41 14 | #define NOTE_F1 44 15 | #define NOTE_FS1 46 16 | #define NOTE_G1 49 17 | #define NOTE_GS1 52 18 | #define NOTE_A1 55 19 | #define NOTE_AS1 58 20 | #define NOTE_B1 62 21 | #define NOTE_C2 65 22 | #define NOTE_CS2 69 23 | #define NOTE_D2 73 24 | #define NOTE_DS2 78 25 | #define NOTE_E2 82 26 | #define NOTE_F2 87 27 | #define NOTE_FS2 93 28 | #define NOTE_G2 98 29 | #define NOTE_GS2 104 30 | #define NOTE_A2 110 31 | #define NOTE_AS2 117 32 | #define NOTE_B2 123 33 | #define NOTE_C3 131 34 | #define NOTE_CS3 139 35 | #define NOTE_D3 147 36 | #define NOTE_DS3 156 37 | #define NOTE_E3 165 38 | #define NOTE_F3 175 39 | #define NOTE_FS3 185 40 | #define NOTE_G3 196 41 | #define NOTE_GS3 208 42 | #define NOTE_A3 220 43 | #define NOTE_AS3 233 44 | #define NOTE_B3 247 45 | #define NOTE_C4 262 46 | #define NOTE_CS4 277 47 | #define NOTE_D4 294 48 | #define NOTE_DS4 311 49 | #define NOTE_E4 330 50 | #define NOTE_F4 349 51 | #define NOTE_FS4 370 52 | #define NOTE_G4 392 53 | #define NOTE_GS4 415 54 | #define NOTE_A4 440 55 | #define NOTE_AS4 466 56 | #define NOTE_B4 494 57 | #define NOTE_C5 523 58 | #define NOTE_CS5 554 59 | #define NOTE_D5 587 60 | #define NOTE_DS5 622 61 | #define NOTE_E5 659 62 | #define NOTE_F5 698 63 | #define NOTE_FS5 740 64 | #define NOTE_G5 784 65 | #define NOTE_GS5 831 66 | #define NOTE_A5 880 67 | #define NOTE_AS5 932 68 | #define NOTE_B5 988 69 | #define NOTE_C6 1047 70 | #define NOTE_CS6 1109 71 | #define NOTE_D6 1175 72 | #define NOTE_DS6 1245 73 | #define NOTE_E6 1319 74 | #define NOTE_F6 1397 75 | #define NOTE_FS6 1480 76 | #define NOTE_G6 1568 77 | #define NOTE_GS6 1661 78 | #define NOTE_A6 1760 79 | #define NOTE_AS6 1865 80 | #define NOTE_B6 1976 81 | #define NOTE_C7 2093 82 | #define NOTE_CS7 2217 83 | #define NOTE_D7 2349 84 | #define NOTE_DS7 2489 85 | #define NOTE_E7 2637 86 | #define NOTE_F7 2794 87 | #define NOTE_FS7 2960 88 | #define NOTE_G7 3136 89 | #define NOTE_GS7 3322 90 | #define NOTE_A7 3520 91 | #define NOTE_AS7 3729 92 | #define NOTE_B7 3951 93 | #define NOTE_C8 4186 94 | #define NOTE_CS8 4435 95 | #define NOTE_D8 4699 96 | #define NOTE_DS8 4978 97 | #define REST 0 98 | 99 | 100 | // change this to make the song slower or faster 101 | int tempo = 70; 102 | 103 | // change this to whichever pin you want to use 104 | int buzzer = 11; 105 | 106 | // notes of the moledy followed by the duration. 107 | // a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on 108 | // !!negative numbers are used to represent dotted notes, 109 | // so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!! 110 | int melody[] = { 111 | 112 | // Greensleeves 113 | // Score available at https://musescore.com/user/168402/scores/1396946 114 | // Alexander Trompoukis 115 | 116 | NOTE_G4,8,//1 117 | NOTE_AS4,4, NOTE_C5,8, NOTE_D5,-8, NOTE_DS5,16, NOTE_D5,8, 118 | NOTE_C5,4, NOTE_A4,8, NOTE_F4,-8, NOTE_G4,16, NOTE_A4,8, 119 | NOTE_AS4,4, NOTE_G4,8, NOTE_G4,-8, NOTE_FS4,16, NOTE_G4,8, 120 | NOTE_A4,4, NOTE_FS4,8, NOTE_D4,4, NOTE_G4,8, 121 | 122 | NOTE_AS4,4, NOTE_C5,8, NOTE_D5,-8, NOTE_DS5,16, NOTE_D5,8,//6 123 | NOTE_C5,4, NOTE_A4,8, NOTE_F4,-8, NOTE_G4,16, NOTE_A4,8, 124 | NOTE_AS4,-8, NOTE_A4,16, NOTE_G4,8, NOTE_FS4,-8, NOTE_E4,16, NOTE_FS4,8, 125 | NOTE_G4,-2, 126 | NOTE_F5,2, NOTE_E5,16, NOTE_D5,8, 127 | 128 | NOTE_C5,4, NOTE_A4,8, NOTE_F4,-8, NOTE_G4,16, NOTE_A4,8,//11 129 | NOTE_AS4,4, NOTE_G4,8, NOTE_G4,-8, NOTE_FS4,16, NOTE_G4,8, 130 | NOTE_A4,4, NOTE_FS4,8, NOTE_D4,04, 131 | NOTE_F5,2, NOTE_E5,16, NOTE_D5,8, 132 | NOTE_C5,4, NOTE_A4,8, NOTE_F4,-8, NOTE_G4,16, NOTE_A4,8, 133 | 134 | NOTE_AS4,-8, NOTE_A4,16, NOTE_G4,8, NOTE_FS4,-8, NOTE_E4,16, NOTE_FS4,8,//16 135 | NOTE_G4,-2, 136 | 137 | //repeats from the beginning 138 | 139 | NOTE_G4,8,//1 140 | NOTE_AS4,4, NOTE_C5,8, NOTE_D5,-8, NOTE_DS5,16, NOTE_D5,8, 141 | NOTE_C5,4, NOTE_A4,8, NOTE_F4,-8, NOTE_G4,16, NOTE_A4,8, 142 | NOTE_AS4,4, NOTE_G4,8, NOTE_G4,-8, NOTE_FS4,16, NOTE_G4,8, 143 | NOTE_A4,4, NOTE_FS4,8, NOTE_D4,4, NOTE_G4,8, 144 | 145 | NOTE_AS4,4, NOTE_C5,8, NOTE_D5,-8, NOTE_DS5,16, NOTE_D5,8,//6 146 | NOTE_C5,4, NOTE_A4,8, NOTE_F4,-8, NOTE_G4,16, NOTE_A4,8, 147 | NOTE_AS4,-8, NOTE_A4,16, NOTE_G4,8, NOTE_FS4,-8, NOTE_E4,16, NOTE_FS4,8, 148 | NOTE_G4,-2, 149 | NOTE_F5,2, NOTE_E5,16, NOTE_D5,8, 150 | 151 | NOTE_C5,4, NOTE_A4,8, NOTE_F4,-8, NOTE_G4,16, NOTE_A4,8,//11 152 | NOTE_AS4,4, NOTE_G4,8, NOTE_G4,-8, NOTE_FS4,16, NOTE_G4,8, 153 | NOTE_A4,4, NOTE_FS4,8, NOTE_D4,04, 154 | NOTE_F5,2, NOTE_E5,16, NOTE_D5,8, 155 | NOTE_C5,4, NOTE_A4,8, NOTE_F4,-8, NOTE_G4,16, NOTE_A4,8, 156 | 157 | NOTE_AS4,-8, NOTE_A4,16, NOTE_G4,8, NOTE_FS4,-8, NOTE_E4,16, NOTE_FS4,8,//16 158 | NOTE_G4,-2 159 | 160 | 161 | }; 162 | 163 | // sizeof gives the number of bytes, each int value is composed of two bytes (16 bits) 164 | // there are two values per note (pitch and duration), so for each note there are four bytes 165 | int notes = sizeof(melody) / sizeof(melody[0]) / 2; 166 | 167 | // this calculates the duration of a whole note in ms 168 | int wholenote = (60000 * 4) / tempo; 169 | 170 | int divider = 0, noteDuration = 0; 171 | 172 | void setup() { 173 | // iterate over the notes of the melody. 174 | // Remember, the array is twice the number of notes (notes + durations) 175 | for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) { 176 | 177 | // calculates the duration of each note 178 | divider = melody[thisNote + 1]; 179 | if (divider > 0) { 180 | // regular note, just proceed 181 | noteDuration = (wholenote) / divider; 182 | } else if (divider < 0) { 183 | // dotted notes are represented with negative durations!! 184 | noteDuration = (wholenote) / abs(divider); 185 | noteDuration *= 1.5; // increases the duration in half for dotted notes 186 | } 187 | 188 | // we only play the note for 90% of the duration, leaving 10% as a pause 189 | tone(buzzer, melody[thisNote], noteDuration*0.9); 190 | 191 | // Wait for the specief duration before playing the next note. 192 | delay(noteDuration); 193 | 194 | // stop the waveform generation before the next note. 195 | noTone(buzzer); 196 | } 197 | } 198 | 199 | void loop() { 200 | // no need to repeat the melody. 201 | } 202 | -------------------------------------------------------------------------------- /princeigor/princeigor.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Prince Igor - Borodin 3 | Connect a piezo buzzer or speaker to pin 11 or select a new pin. 4 | More songs available at https://github.com/robsoncouto/arduino-songs 5 | 6 | Robson Couto, 2019 7 | */ 8 | 9 | #define NOTE_B0 31 10 | #define NOTE_C1 33 11 | #define NOTE_CS1 35 12 | #define NOTE_D1 37 13 | #define NOTE_DS1 39 14 | #define NOTE_E1 41 15 | #define NOTE_F1 44 16 | #define NOTE_FS1 46 17 | #define NOTE_G1 49 18 | #define NOTE_GS1 52 19 | #define NOTE_A1 55 20 | #define NOTE_AS1 58 21 | #define NOTE_B1 62 22 | #define NOTE_C2 65 23 | #define NOTE_CS2 69 24 | #define NOTE_D2 73 25 | #define NOTE_DS2 78 26 | #define NOTE_E2 82 27 | #define NOTE_F2 87 28 | #define NOTE_FS2 93 29 | #define NOTE_G2 98 30 | #define NOTE_GS2 104 31 | #define NOTE_A2 110 32 | #define NOTE_AS2 117 33 | #define NOTE_B2 123 34 | #define NOTE_C3 131 35 | #define NOTE_CS3 139 36 | #define NOTE_D3 147 37 | #define NOTE_DS3 156 38 | #define NOTE_E3 165 39 | #define NOTE_F3 175 40 | #define NOTE_FS3 185 41 | #define NOTE_G3 196 42 | #define NOTE_GS3 208 43 | #define NOTE_A3 220 44 | #define NOTE_AS3 233 45 | #define NOTE_B3 247 46 | #define NOTE_C4 262 47 | #define NOTE_CS4 277 48 | #define NOTE_D4 294 49 | #define NOTE_DS4 311 50 | #define NOTE_E4 330 51 | #define NOTE_F4 349 52 | #define NOTE_FS4 370 53 | #define NOTE_G4 392 54 | #define NOTE_GS4 415 55 | #define NOTE_A4 440 56 | #define NOTE_AS4 466 57 | #define NOTE_B4 494 58 | #define NOTE_C5 523 59 | #define NOTE_CS5 554 60 | #define NOTE_D5 587 61 | #define NOTE_DS5 622 62 | #define NOTE_E5 659 63 | #define NOTE_F5 698 64 | #define NOTE_FS5 740 65 | #define NOTE_G5 784 66 | #define NOTE_GS5 831 67 | #define NOTE_A5 880 68 | #define NOTE_AS5 932 69 | #define NOTE_B5 988 70 | #define NOTE_C6 1047 71 | #define NOTE_CS6 1109 72 | #define NOTE_D6 1175 73 | #define NOTE_DS6 1245 74 | #define NOTE_E6 1319 75 | #define NOTE_F6 1397 76 | #define NOTE_FS6 1480 77 | #define NOTE_G6 1568 78 | #define NOTE_GS6 1661 79 | #define NOTE_A6 1760 80 | #define NOTE_AS6 1865 81 | #define NOTE_B6 1976 82 | #define NOTE_C7 2093 83 | #define NOTE_CS7 2217 84 | #define NOTE_D7 2349 85 | #define NOTE_DS7 2489 86 | #define NOTE_E7 2637 87 | #define NOTE_F7 2794 88 | #define NOTE_FS7 2960 89 | #define NOTE_G7 3136 90 | #define NOTE_GS7 3322 91 | #define NOTE_A7 3520 92 | #define NOTE_AS7 3729 93 | #define NOTE_B7 3951 94 | #define NOTE_C8 4186 95 | #define NOTE_CS8 4435 96 | #define NOTE_D8 4699 97 | #define NOTE_DS8 4978 98 | #define REST 0 99 | 100 | 101 | // change this to make the song slower or faster 102 | int tempo = 110; 103 | 104 | // change this to whichever pin you want to use 105 | int buzzer = 11; 106 | 107 | // notes of the moledy followed by the duration. 108 | // a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on 109 | // !!negative numbers are used to represent dotted notes, 110 | // so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!! 111 | int melody[] = { 112 | 113 | // Prince Igor - Polovtsian Dances, Borodin 114 | NOTE_G4, 4, NOTE_G4, 4, NOTE_D5, -2, 115 | NOTE_C5, 8, NOTE_D5, 8, NOTE_AS4, 4, NOTE_A4, 8, NOTE_G4, 8, 116 | NOTE_A4, 8, NOTE_AS4, 8, NOTE_C5, 1, 117 | 118 | NOTE_D5, 4, NOTE_A4, 4, NOTE_G4, 8, NOTE_F4, 8, 119 | NOTE_D4, 4, NOTE_D4, 4, NOTE_G4, -2, 120 | NOTE_A4, 4, NOTE_G4, 4, NOTE_F4, 8, NOTE_E4, 8, 121 | 122 | NOTE_F4, 4, NOTE_E4, 4, NOTE_D4, 1, 123 | NOTE_E4, 4, NOTE_F4, 4, NOTE_A4, 4, 124 | NOTE_G4, 4, NOTE_G4, 4, NOTE_AS4, -2, 125 | 126 | NOTE_C5, 4, NOTE_AS4, 4, NOTE_A4, 8, NOTE_G4, 8, 127 | NOTE_A4, 4, NOTE_AS4, 4, NOTE_C5, -2, 128 | NOTE_CS5, 4, NOTE_C5, 4, NOTE_A4, 4, 129 | 130 | NOTE_CS5, 4, NOTE_CS4, 4, NOTE_F5, -2, 131 | NOTE_G5, 4, NOTE_F5, 4, NOTE_DS4, 8, NOTE_CS4, 8, 132 | NOTE_F5, 2, NOTE_C5, -2, 133 | 134 | NOTE_AS4, 4, NOTE_C5, 4, NOTE_AS4, 8, NOTE_A4, 8, 135 | NOTE_G4, 4, NOTE_G4, 4, NOTE_AS4, 1, 136 | NOTE_C5, 4, NOTE_AS4, 4, NOTE_A4, 8, NOTE_G4, 8, 137 | 138 | NOTE_F4, 4, NOTE_G4, 4, NOTE_A4, 1, 139 | NOTE_AS4, 4, NOTE_A4, 4, NOTE_F4, 4, 140 | NOTE_G4, 4, NOTE_G4, 4, NOTE_D5, -2, 141 | 142 | NOTE_C5, 4, NOTE_AS4, 4, NOTE_A4, 8, NOTE_G4, 8, 143 | NOTE_A4,-1, NOTE_A4,-1, REST,2, 144 | NOTE_G4, 4, NOTE_G4, 4, NOTE_D5, -2, 145 | 146 | NOTE_C5, 8, NOTE_D5, 8, NOTE_AS4, 4, NOTE_A4, 8, NOTE_G4, 8, 147 | NOTE_A4, 8, NOTE_AS4, 8, NOTE_C5, 1, 148 | NOTE_C5, 8, NOTE_D5, 8, NOTE_C5, 4, NOTE_AS4, 8, NOTE_A4, 8, 149 | 150 | 151 | NOTE_D4, 4, NOTE_D4, 4, NOTE_G4, -2, 152 | NOTE_G4, 8, NOTE_A4, 8, NOTE_G4, 4, NOTE_F4, 8, NOTE_E4, 8, 153 | NOTE_F4, 8, NOTE_E4, 8, NOTE_D4, -2,//1 154 | 155 | REST,4, NOTE_C5, 8, NOTE_D5, 8, NOTE_C5, 4, NOTE_AS4, 8, NOTE_A4, 8, 156 | NOTE_G4, 4, NOTE_G4, 4, NOTE_B4, -2, 157 | NOTE_C5, 4, NOTE_AS4, 4, NOTE_A4, 8, NOTE_G4, 8, 158 | 159 | NOTE_A4, 4, NOTE_G4, 4, NOTE_F4, -1, REST,4, 160 | NOTE_G4, 4, NOTE_G4, 4, NOTE_D5, -2, 161 | NOTE_C5, 8, NOTE_D5, 8, NOTE_AS4, 4, NOTE_A4, 8, NOTE_G4, 8, 162 | 163 | NOTE_A4, 4, NOTE_G4, 4, NOTE_F4, -2, 164 | NOTE_A4, 4, NOTE_G4, 4, NOTE_F4, -2, 165 | NOTE_A4, 4, NOTE_G4, 4, NOTE_F4, -1, 166 | 167 | }; 168 | 169 | // sizeof gives the number of bytes, each int value is composed of two bytes (16 bits) 170 | // there are two values per note (pitch and duration), so for each note there are four bytes 171 | int notes = sizeof(melody) / sizeof(melody[0]) / 2; 172 | 173 | // this calculates the duration of a whole note in ms (60s/tempo)*4 beats 174 | int wholenote = (60000 * 4) / tempo; 175 | 176 | int divider = 0, noteDuration = 0; 177 | 178 | void setup() { 179 | // iterate over the notes of the melody. 180 | // Remember, the array is twice the number of notes (notes + durations) 181 | for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) { 182 | 183 | // calculates the duration of each note 184 | divider = melody[thisNote + 1]; 185 | if (divider > 0) { 186 | // regular note, just proceed 187 | noteDuration = (wholenote) / divider; 188 | } else if (divider < 0) { 189 | // dotted notes are represented with negative durations!! 190 | noteDuration = (wholenote) / abs(divider); 191 | noteDuration *= 1.5; // increases the duration in half for dotted notes 192 | } 193 | 194 | // we only play the note for 90% of the duration, leaving 10% as a pause 195 | tone(buzzer, melody[thisNote], noteDuration*0.9); 196 | 197 | // Wait for the specief duration before playing the next note. 198 | delay(noteDuration); 199 | 200 | // stop the waveform generation before the next note. 201 | noTone(buzzer); 202 | } 203 | } 204 | 205 | void loop() { 206 | // no need to repeat the melody. 207 | } 208 | -------------------------------------------------------------------------------- /greenhill/greenhill.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Green Hill Zone's theme - Sonic the Hedgehog 3 | Connect a piezo buzzer or speaker to pin 11 or select a new pin. 4 | More songs available at https://github.com/robsoncouto/arduino-songs 5 | 6 | Robson Couto, 2019 7 | */ 8 | #define NOTE_B0 31 9 | #define NOTE_C1 33 10 | #define NOTE_CS1 35 11 | #define NOTE_D1 37 12 | #define NOTE_DS1 39 13 | #define NOTE_E1 41 14 | #define NOTE_F1 44 15 | #define NOTE_FS1 46 16 | #define NOTE_G1 49 17 | #define NOTE_GS1 52 18 | #define NOTE_A1 55 19 | #define NOTE_AS1 58 20 | #define NOTE_B1 62 21 | #define NOTE_C2 65 22 | #define NOTE_CS2 69 23 | #define NOTE_D2 73 24 | #define NOTE_DS2 78 25 | #define NOTE_E2 82 26 | #define NOTE_F2 87 27 | #define NOTE_FS2 93 28 | #define NOTE_G2 98 29 | #define NOTE_GS2 104 30 | #define NOTE_A2 110 31 | #define NOTE_AS2 117 32 | #define NOTE_B2 123 33 | #define NOTE_C3 131 34 | #define NOTE_CS3 139 35 | #define NOTE_D3 147 36 | #define NOTE_DS3 156 37 | #define NOTE_E3 165 38 | #define NOTE_F3 175 39 | #define NOTE_FS3 185 40 | #define NOTE_G3 196 41 | #define NOTE_GS3 208 42 | #define NOTE_A3 220 43 | #define NOTE_AS3 233 44 | #define NOTE_B3 247 45 | #define NOTE_C4 262 46 | #define NOTE_CS4 277 47 | #define NOTE_D4 294 48 | #define NOTE_DS4 311 49 | #define NOTE_E4 330 50 | #define NOTE_F4 349 51 | #define NOTE_FS4 370 52 | #define NOTE_G4 392 53 | #define NOTE_GS4 415 54 | #define NOTE_A4 440 55 | #define NOTE_AS4 466 56 | #define NOTE_B4 494 57 | #define NOTE_C5 523 58 | #define NOTE_CS5 554 59 | #define NOTE_D5 587 60 | #define NOTE_DS5 622 61 | #define NOTE_E5 659 62 | #define NOTE_F5 698 63 | #define NOTE_FS5 740 64 | #define NOTE_G5 784 65 | #define NOTE_GS5 831 66 | #define NOTE_A5 880 67 | #define NOTE_AS5 932 68 | #define NOTE_B5 988 69 | #define NOTE_C6 1047 70 | #define NOTE_CS6 1109 71 | #define NOTE_D6 1175 72 | #define NOTE_DS6 1245 73 | #define NOTE_E6 1319 74 | #define NOTE_F6 1397 75 | #define NOTE_FS6 1480 76 | #define NOTE_G6 1568 77 | #define NOTE_GS6 1661 78 | #define NOTE_A6 1760 79 | #define NOTE_AS6 1865 80 | #define NOTE_B6 1976 81 | #define NOTE_C7 2093 82 | #define NOTE_CS7 2217 83 | #define NOTE_D7 2349 84 | #define NOTE_DS7 2489 85 | #define NOTE_E7 2637 86 | #define NOTE_F7 2794 87 | #define NOTE_FS7 2960 88 | #define NOTE_G7 3136 89 | #define NOTE_GS7 3322 90 | #define NOTE_A7 3520 91 | #define NOTE_AS7 3729 92 | #define NOTE_B7 3951 93 | #define NOTE_C8 4186 94 | #define NOTE_CS8 4435 95 | #define NOTE_D8 4699 96 | #define NOTE_DS8 4978 97 | #define REST 0 98 | 99 | 100 | // change this to make the song slower or faster 101 | int tempo = 140; 102 | 103 | // change this to whichever pin you want to use 104 | int buzzer = 11; 105 | 106 | // notes of the moledy followed by the duration. 107 | // a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on 108 | // !!negative numbers are used to represent dotted notes, 109 | // so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!! 110 | int melody[] = { 111 | 112 | // Gren Hill Zone - Sonic the Hedgehog 113 | // Score available at https://musescore.com/user/248346/scores/461661 114 | // Theme by Masato Nakamura, arranged by Teddy Mason 115 | 116 | REST,2, NOTE_D5,8, NOTE_B4,4, NOTE_D5,8, //1 117 | NOTE_CS5,4, NOTE_D5,8, NOTE_CS5,4, NOTE_A4,2, 118 | REST,8, NOTE_A4,8, NOTE_FS5,8, NOTE_E5,4, NOTE_D5,8, 119 | NOTE_CS5,4, NOTE_D5,8, NOTE_CS5,4, NOTE_A4,2, 120 | REST,4, NOTE_D5,8, NOTE_B4,4, NOTE_D5,8, 121 | NOTE_CS5,4, NOTE_D5,8, NOTE_CS5,4, NOTE_A4,2, 122 | 123 | REST,8, NOTE_B4,8, NOTE_B4,8, NOTE_G4,4, NOTE_B4,8, //7 124 | NOTE_A4,4, NOTE_B4,8, NOTE_A4,4, NOTE_D4,2, 125 | REST,4, NOTE_D5,8, NOTE_B4,4, NOTE_D5,8, 126 | NOTE_CS5,4, NOTE_D5,8, NOTE_CS5,4, NOTE_A4,2, 127 | REST,8, NOTE_A4,8, NOTE_FS5,8, NOTE_E5,4, NOTE_D5,8, 128 | NOTE_CS5,4, NOTE_D5,8, NOTE_CS5,4, NOTE_A4,2, 129 | 130 | REST,4, NOTE_D5,8, NOTE_B4,4, NOTE_D5,8, //13 131 | NOTE_CS5,4, NOTE_D5,8, NOTE_CS5,4, NOTE_A4,2, 132 | REST,8, NOTE_B4,8, NOTE_B4,8, NOTE_G4,4, NOTE_B4,8, 133 | NOTE_A4,4, NOTE_B4,8, NOTE_A4,4, NOTE_D4,8, NOTE_D4,8, NOTE_FS4,8, 134 | NOTE_E4,-1, 135 | REST,8, NOTE_D4,8, NOTE_E4,8, NOTE_FS4,-1, 136 | 137 | REST,8, NOTE_D4,8, NOTE_D4,8, NOTE_FS4,8, NOTE_F4,-1, //20 138 | REST,8, NOTE_D4,8, NOTE_F4,8, NOTE_E4,-1, //end 1 139 | 140 | //repeats from 1 141 | 142 | REST,2, NOTE_D5,8, NOTE_B4,4, NOTE_D5,8, //1 143 | NOTE_CS5,4, NOTE_D5,8, NOTE_CS5,4, NOTE_A4,2, 144 | REST,8, NOTE_A4,8, NOTE_FS5,8, NOTE_E5,4, NOTE_D5,8, 145 | NOTE_CS5,4, NOTE_D5,8, NOTE_CS5,4, NOTE_A4,2, 146 | REST,4, NOTE_D5,8, NOTE_B4,4, NOTE_D5,8, 147 | NOTE_CS5,4, NOTE_D5,8, NOTE_CS5,4, NOTE_A4,2, 148 | 149 | REST,8, NOTE_B4,8, NOTE_B4,8, NOTE_G4,4, NOTE_B4,8, //7 150 | NOTE_A4,4, NOTE_B4,8, NOTE_A4,4, NOTE_D4,2, 151 | REST,4, NOTE_D5,8, NOTE_B4,4, NOTE_D5,8, 152 | NOTE_CS5,4, NOTE_D5,8, NOTE_CS5,4, NOTE_A4,2, 153 | REST,8, NOTE_A4,8, NOTE_FS5,8, NOTE_E5,4, NOTE_D5,8, 154 | NOTE_CS5,4, NOTE_D5,8, NOTE_CS5,4, NOTE_A4,2, 155 | 156 | REST,4, NOTE_D5,8, NOTE_B4,4, NOTE_D5,8, //13 157 | NOTE_CS5,4, NOTE_D5,8, NOTE_CS5,4, NOTE_A4,2, 158 | REST,8, NOTE_B4,8, NOTE_B4,8, NOTE_G4,4, NOTE_B4,8, 159 | NOTE_A4,4, NOTE_B4,8, NOTE_A4,4, NOTE_D4,8, NOTE_D4,8, NOTE_FS4,8, 160 | NOTE_E4,-1, 161 | REST,8, NOTE_D4,8, NOTE_E4,8, NOTE_FS4,-1, 162 | 163 | REST,8, NOTE_D4,8, NOTE_D4,8, NOTE_FS4,8, NOTE_F4,-1, //20 164 | REST,8, NOTE_D4,8, NOTE_F4,8, NOTE_E4,8, //end 2 165 | NOTE_E4,-2, NOTE_A4,8, NOTE_CS5,8, 166 | NOTE_FS5,8, NOTE_E5,4, NOTE_D5,8, NOTE_A5,-4, 167 | 168 | }; 169 | 170 | // sizeof gives the number of bytes, each int value is composed of two bytes (16 bits) 171 | // there are two values per note (pitch and duration), so for each note there are four bytes 172 | int notes = sizeof(melody) / sizeof(melody[0]) / 2; 173 | 174 | // this calculates the duration of a whole note in ms 175 | int wholenote = (60000 * 4) / tempo; 176 | 177 | int divider = 0, noteDuration = 0; 178 | 179 | void setup() { 180 | // iterate over the notes of the melody. 181 | // Remember, the array is twice the number of notes (notes + durations) 182 | for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) { 183 | 184 | // calculates the duration of each note 185 | divider = melody[thisNote + 1]; 186 | if (divider > 0) { 187 | // regular note, just proceed 188 | noteDuration = (wholenote) / divider; 189 | } else if (divider < 0) { 190 | // dotted notes are represented with negative durations!! 191 | noteDuration = (wholenote) / abs(divider); 192 | noteDuration *= 1.5; // increases the duration in half for dotted notes 193 | } 194 | 195 | // we only play the note for 90% of the duration, leaving 10% as a pause 196 | tone(buzzer, melody[thisNote], noteDuration * 0.9); 197 | 198 | // Wait for the specief duration before playing the next note. 199 | delay(noteDuration); 200 | 201 | // stop the waveform generation before the next note. 202 | noTone(buzzer); 203 | } 204 | } 205 | 206 | void loop() { 207 | // no need to repeat the melody. 208 | } 209 | -------------------------------------------------------------------------------- /minuetg/minuetg.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Minuet in G - C. Petzold 3 | Connect a piezo buzzer or speaker to pin 11 or select a new pin. 4 | More songs available at https://github.com/robsoncouto/arduino-songs 5 | 6 | Robson Couto, 2019 7 | */ 8 | #define NOTE_B0 31 9 | #define NOTE_C1 33 10 | #define NOTE_CS1 35 11 | #define NOTE_D1 37 12 | #define NOTE_DS1 39 13 | #define NOTE_E1 41 14 | #define NOTE_F1 44 15 | #define NOTE_FS1 46 16 | #define NOTE_G1 49 17 | #define NOTE_GS1 52 18 | #define NOTE_A1 55 19 | #define NOTE_AS1 58 20 | #define NOTE_B1 62 21 | #define NOTE_C2 65 22 | #define NOTE_CS2 69 23 | #define NOTE_D2 73 24 | #define NOTE_DS2 78 25 | #define NOTE_E2 82 26 | #define NOTE_F2 87 27 | #define NOTE_FS2 93 28 | #define NOTE_G2 98 29 | #define NOTE_GS2 104 30 | #define NOTE_A2 110 31 | #define NOTE_AS2 117 32 | #define NOTE_B2 123 33 | #define NOTE_C3 131 34 | #define NOTE_CS3 139 35 | #define NOTE_D3 147 36 | #define NOTE_DS3 156 37 | #define NOTE_E3 165 38 | #define NOTE_F3 175 39 | #define NOTE_FS3 185 40 | #define NOTE_G3 196 41 | #define NOTE_GS3 208 42 | #define NOTE_A3 220 43 | #define NOTE_AS3 233 44 | #define NOTE_B3 247 45 | #define NOTE_C4 262 46 | #define NOTE_CS4 277 47 | #define NOTE_D4 294 48 | #define NOTE_DS4 311 49 | #define NOTE_E4 330 50 | #define NOTE_F4 349 51 | #define NOTE_FS4 370 52 | #define NOTE_G4 392 53 | #define NOTE_GS4 415 54 | #define NOTE_A4 440 55 | #define NOTE_AS4 466 56 | #define NOTE_B4 494 57 | #define NOTE_C5 523 58 | #define NOTE_CS5 554 59 | #define NOTE_D5 587 60 | #define NOTE_DS5 622 61 | #define NOTE_E5 659 62 | #define NOTE_F5 698 63 | #define NOTE_FS5 740 64 | #define NOTE_G5 784 65 | #define NOTE_GS5 831 66 | #define NOTE_A5 880 67 | #define NOTE_AS5 932 68 | #define NOTE_B5 988 69 | #define NOTE_C6 1047 70 | #define NOTE_CS6 1109 71 | #define NOTE_D6 1175 72 | #define NOTE_DS6 1245 73 | #define NOTE_E6 1319 74 | #define NOTE_F6 1397 75 | #define NOTE_FS6 1480 76 | #define NOTE_G6 1568 77 | #define NOTE_GS6 1661 78 | #define NOTE_A6 1760 79 | #define NOTE_AS6 1865 80 | #define NOTE_B6 1976 81 | #define NOTE_C7 2093 82 | #define NOTE_CS7 2217 83 | #define NOTE_D7 2349 84 | #define NOTE_DS7 2489 85 | #define NOTE_E7 2637 86 | #define NOTE_F7 2794 87 | #define NOTE_FS7 2960 88 | #define NOTE_G7 3136 89 | #define NOTE_GS7 3322 90 | #define NOTE_A7 3520 91 | #define NOTE_AS7 3729 92 | #define NOTE_B7 3951 93 | #define NOTE_C8 4186 94 | #define NOTE_CS8 4435 95 | #define NOTE_D8 4699 96 | #define NOTE_DS8 4978 97 | #define REST 0 98 | 99 | 100 | // change this to make the song slower or faster 101 | int tempo = 140; 102 | 103 | // change this to whichever pin you want to use 104 | int buzzer = 11; 105 | 106 | // notes of the moledy followed by the duration. 107 | // a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on 108 | // !!negative numbers are used to represent dotted notes, 109 | // so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!! 110 | int melody[] = { 111 | 112 | // Minuet in G - Petzold 113 | // Score available at https://musescore.com/user/3402766/scores/1456391 114 | NOTE_D5,4, NOTE_G4,8, NOTE_A4,8, NOTE_B4,8, NOTE_C5,8, //1 115 | NOTE_D5,4, NOTE_G4,4, NOTE_G4,4, 116 | NOTE_E5,4, NOTE_C5,8, NOTE_D5,8, NOTE_E5,8, NOTE_FS5,8, 117 | NOTE_G5,4, NOTE_G4,4, NOTE_G4,4, 118 | NOTE_C5,4, NOTE_D5,8, NOTE_C5,8, NOTE_B4,8, NOTE_A4,8, 119 | 120 | NOTE_B4,4, NOTE_C5,8, NOTE_B4,8, NOTE_A4,8, NOTE_G4,8,//6 121 | NOTE_FS4,4, NOTE_G4,8, NOTE_A4,8, NOTE_B4,8, NOTE_G4,8, 122 | NOTE_A4,-2, 123 | NOTE_D5,4, NOTE_G4,8, NOTE_A4,8, NOTE_B4,8, NOTE_C5,8, 124 | NOTE_D5,4, NOTE_G4,4, NOTE_G4,4, 125 | NOTE_E5,4, NOTE_C5,8, NOTE_D5,8, NOTE_E5,8, NOTE_FS5,8, 126 | 127 | NOTE_G5,4, NOTE_G4,4, NOTE_G4,4, 128 | NOTE_C5,4, NOTE_D5,8, NOTE_C5,8, NOTE_B4,8, NOTE_A4,8, //12 129 | NOTE_B4,4, NOTE_C5,8, NOTE_B4,8, NOTE_A4,8, NOTE_G4,8, 130 | NOTE_A4,4, NOTE_B4,8, NOTE_A4,8, NOTE_G4,8, NOTE_FS4,8, 131 | NOTE_G4,-2, 132 | 133 | //repeats from 1 134 | 135 | NOTE_D5,4, NOTE_G4,8, NOTE_A4,8, NOTE_B4,8, NOTE_C5,8, //1 136 | NOTE_D5,4, NOTE_G4,4, NOTE_G4,4, 137 | NOTE_E5,4, NOTE_C5,8, NOTE_D5,8, NOTE_E5,8, NOTE_FS5,8, 138 | NOTE_G5,4, NOTE_G4,4, NOTE_G4,4, 139 | NOTE_C5,4, NOTE_D5,8, NOTE_C5,8, NOTE_B4,8, NOTE_A4,8, 140 | 141 | NOTE_B4,4, NOTE_C5,8, NOTE_B4,8, NOTE_A4,8, NOTE_G4,8,//6 142 | NOTE_FS4,4, NOTE_G4,8, NOTE_A4,8, NOTE_B4,8, NOTE_G4,8, 143 | NOTE_A4,-2, 144 | NOTE_D5,4, NOTE_G4,8, NOTE_A4,8, NOTE_B4,8, NOTE_C5,8, 145 | NOTE_D5,4, NOTE_G4,4, NOTE_G4,4, 146 | NOTE_E5,4, NOTE_C5,8, NOTE_D5,8, NOTE_E5,8, NOTE_FS5,8, 147 | 148 | NOTE_G5,4, NOTE_G4,4, NOTE_G4,4, 149 | NOTE_C5,4, NOTE_D5,8, NOTE_C5,8, NOTE_B4,8, NOTE_A4,8, //12 150 | NOTE_B4,4, NOTE_C5,8, NOTE_B4,8, NOTE_A4,8, NOTE_G4,8, 151 | NOTE_A4,4, NOTE_B4,8, NOTE_A4,8, NOTE_G4,8, NOTE_FS4,8, 152 | NOTE_G4,-2, 153 | 154 | //continues from 17 155 | 156 | NOTE_B5,4, NOTE_G5,8, NOTE_A5,8, NOTE_B5,8, NOTE_G5,8,//17 157 | NOTE_A5,4, NOTE_D5,8, NOTE_E5,8, NOTE_FS5,8, NOTE_D5,8, 158 | NOTE_G5,4, NOTE_E5,8, NOTE_FS5,8, NOTE_G5,8, NOTE_D5,8, 159 | NOTE_CS5,4, NOTE_B4,8, NOTE_CS5,8, NOTE_A4,4, 160 | NOTE_A4,8, NOTE_B4,8, NOTE_CS5,8, NOTE_D5,8, NOTE_E5,8, NOTE_FS5,8, 161 | 162 | NOTE_G5,4, NOTE_FS5,4, NOTE_E5,4, //22 163 | NOTE_FS5,4, NOTE_A4,4, NOTE_CS5,4, 164 | NOTE_D5,-2, 165 | NOTE_D5,4, NOTE_G4,8, NOTE_FS5,8, NOTE_G4,4, 166 | NOTE_E5,4, NOTE_G4,8, NOTE_FS4,8, NOTE_G4,4, 167 | NOTE_D5,4, NOTE_C5,4, NOTE_B4,4, 168 | 169 | NOTE_A4,8, NOTE_G4,8, NOTE_FS4,8, NOTE_G4,8, NOTE_A4,4, //28 170 | NOTE_D4,8, NOTE_E4,8, NOTE_FS4,8, NOTE_G4,8, NOTE_A4,8, NOTE_B4,8, 171 | NOTE_C5,4, NOTE_B4,4, NOTE_A4,4, 172 | NOTE_B4,8, NOTE_D5,8, NOTE_G4,4, NOTE_FS4,4, 173 | NOTE_G4,-2, 174 | 175 | 176 | 177 | 178 | 179 | }; 180 | 181 | // sizeof gives the number of bytes, each int value is composed of two bytes (16 bits) 182 | // there are two values per note (pitch and duration), so for each note there are four bytes 183 | int notes = sizeof(melody) / sizeof(melody[0]) / 2; 184 | 185 | // this calculates the duration of a whole note in ms 186 | int wholenote = (60000 * 4) / tempo; 187 | 188 | int divider = 0, noteDuration = 0; 189 | 190 | void setup() { 191 | // iterate over the notes of the melody. 192 | // Remember, the array is twice the number of notes (notes + durations) 193 | for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) { 194 | 195 | // calculates the duration of each note 196 | divider = melody[thisNote + 1]; 197 | if (divider > 0) { 198 | // regular note, just proceed 199 | noteDuration = (wholenote) / divider; 200 | } else if (divider < 0) { 201 | // dotted notes are represented with negative durations!! 202 | noteDuration = (wholenote) / abs(divider); 203 | noteDuration *= 1.5; // increases the duration in half for dotted notes 204 | } 205 | 206 | // we only play the note for 90% of the duration, leaving 10% as a pause 207 | tone(buzzer, melody[thisNote], noteDuration * 0.9); 208 | 209 | // Wait for the specief duration before playing the next note. 210 | delay(noteDuration); 211 | 212 | // stop the waveform generation before the next note. 213 | noTone(buzzer); 214 | } 215 | } 216 | 217 | void loop() { 218 | // no need to repeat the melody. 219 | } 220 | -------------------------------------------------------------------------------- /merrychristmas/merrychristmas.ino: -------------------------------------------------------------------------------- 1 | /* 2 | We Wish You a Merry Christmas - Traditional Christmas song 3 | Connect a piezo buzzer or speaker to pin 11 or select a new pin. 4 | More songs available at https://github.com/robsoncouto/arduino-songs 5 | 6 | Robson Couto, 2019 7 | */ 8 | #define NOTE_B0 31 9 | #define NOTE_C1 33 10 | #define NOTE_CS1 35 11 | #define NOTE_D1 37 12 | #define NOTE_DS1 39 13 | #define NOTE_E1 41 14 | #define NOTE_F1 44 15 | #define NOTE_FS1 46 16 | #define NOTE_G1 49 17 | #define NOTE_GS1 52 18 | #define NOTE_A1 55 19 | #define NOTE_AS1 58 20 | #define NOTE_B1 62 21 | #define NOTE_C2 65 22 | #define NOTE_CS2 69 23 | #define NOTE_D2 73 24 | #define NOTE_DS2 78 25 | #define NOTE_E2 82 26 | #define NOTE_F2 87 27 | #define NOTE_FS2 93 28 | #define NOTE_G2 98 29 | #define NOTE_GS2 104 30 | #define NOTE_A2 110 31 | #define NOTE_AS2 117 32 | #define NOTE_B2 123 33 | #define NOTE_C3 131 34 | #define NOTE_CS3 139 35 | #define NOTE_D3 147 36 | #define NOTE_DS3 156 37 | #define NOTE_E3 165 38 | #define NOTE_F3 175 39 | #define NOTE_FS3 185 40 | #define NOTE_G3 196 41 | #define NOTE_GS3 208 42 | #define NOTE_A3 220 43 | #define NOTE_AS3 233 44 | #define NOTE_B3 247 45 | #define NOTE_C4 262 46 | #define NOTE_CS4 277 47 | #define NOTE_D4 294 48 | #define NOTE_DS4 311 49 | #define NOTE_E4 330 50 | #define NOTE_F4 349 51 | #define NOTE_FS4 370 52 | #define NOTE_G4 392 53 | #define NOTE_GS4 415 54 | #define NOTE_A4 440 55 | #define NOTE_AS4 466 56 | #define NOTE_B4 494 57 | #define NOTE_C5 523 58 | #define NOTE_CS5 554 59 | #define NOTE_D5 587 60 | #define NOTE_DS5 622 61 | #define NOTE_E5 659 62 | #define NOTE_F5 698 63 | #define NOTE_FS5 740 64 | #define NOTE_G5 784 65 | #define NOTE_GS5 831 66 | #define NOTE_A5 880 67 | #define NOTE_AS5 932 68 | #define NOTE_B5 988 69 | #define NOTE_C6 1047 70 | #define NOTE_CS6 1109 71 | #define NOTE_D6 1175 72 | #define NOTE_DS6 1245 73 | #define NOTE_E6 1319 74 | #define NOTE_F6 1397 75 | #define NOTE_FS6 1480 76 | #define NOTE_G6 1568 77 | #define NOTE_GS6 1661 78 | #define NOTE_A6 1760 79 | #define NOTE_AS6 1865 80 | #define NOTE_B6 1976 81 | #define NOTE_C7 2093 82 | #define NOTE_CS7 2217 83 | #define NOTE_D7 2349 84 | #define NOTE_DS7 2489 85 | #define NOTE_E7 2637 86 | #define NOTE_F7 2794 87 | #define NOTE_FS7 2960 88 | #define NOTE_G7 3136 89 | #define NOTE_GS7 3322 90 | #define NOTE_A7 3520 91 | #define NOTE_AS7 3729 92 | #define NOTE_B7 3951 93 | #define NOTE_C8 4186 94 | #define NOTE_CS8 4435 95 | #define NOTE_D8 4699 96 | #define NOTE_DS8 4978 97 | #define REST 0 98 | 99 | 100 | // change this to make the song slower or faster 101 | int tempo = 140; 102 | 103 | // change this to whichever pin you want to use 104 | int buzzer = 11; 105 | 106 | // notes of the moledy followed by the duration. 107 | // a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on 108 | // !!negative numbers are used to represent dotted notes, 109 | // so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!! 110 | int melody[] = { 111 | 112 | // We Wish You a Merry Christmas 113 | // Score available at https://musescore.com/user/6208766/scores/1497501 114 | 115 | NOTE_C5,4, //1 116 | NOTE_F5,4, NOTE_F5,8, NOTE_G5,8, NOTE_F5,8, NOTE_E5,8, 117 | NOTE_D5,4, NOTE_D5,4, NOTE_D5,4, 118 | NOTE_G5,4, NOTE_G5,8, NOTE_A5,8, NOTE_G5,8, NOTE_F5,8, 119 | NOTE_E5,4, NOTE_C5,4, NOTE_C5,4, 120 | NOTE_A5,4, NOTE_A5,8, NOTE_AS5,8, NOTE_A5,8, NOTE_G5,8, 121 | NOTE_F5,4, NOTE_D5,4, NOTE_C5,8, NOTE_C5,8, 122 | NOTE_D5,4, NOTE_G5,4, NOTE_E5,4, 123 | 124 | NOTE_F5,2, NOTE_C5,4, //8 125 | NOTE_F5,4, NOTE_F5,8, NOTE_G5,8, NOTE_F5,8, NOTE_E5,8, 126 | NOTE_D5,4, NOTE_D5,4, NOTE_D5,4, 127 | NOTE_G5,4, NOTE_G5,8, NOTE_A5,8, NOTE_G5,8, NOTE_F5,8, 128 | NOTE_E5,4, NOTE_C5,4, NOTE_C5,4, 129 | NOTE_A5,4, NOTE_A5,8, NOTE_AS5,8, NOTE_A5,8, NOTE_G5,8, 130 | NOTE_F5,4, NOTE_D5,4, NOTE_C5,8, NOTE_C5,8, 131 | NOTE_D5,4, NOTE_G5,4, NOTE_E5,4, 132 | NOTE_F5,2, NOTE_C5,4, 133 | 134 | NOTE_F5,4, NOTE_F5,4, NOTE_F5,4,//17 135 | NOTE_E5,2, NOTE_E5,4, 136 | NOTE_F5,4, NOTE_E5,4, NOTE_D5,4, 137 | NOTE_C5,2, NOTE_A5,4, 138 | NOTE_AS5,4, NOTE_A5,4, NOTE_G5,4, 139 | NOTE_C6,4, NOTE_C5,4, NOTE_C5,8, NOTE_C5,8, 140 | NOTE_D5,4, NOTE_G5,4, NOTE_E5,4, 141 | NOTE_F5,2, NOTE_C5,4, 142 | NOTE_F5,4, NOTE_F5,8, NOTE_G5,8, NOTE_F5,8, NOTE_E5,8, 143 | NOTE_D5,4, NOTE_D5,4, NOTE_D5,4, 144 | 145 | NOTE_G5,4, NOTE_G5,8, NOTE_A5,8, NOTE_G5,8, NOTE_F5,8, //27 146 | NOTE_E5,4, NOTE_C5,4, NOTE_C5,4, 147 | NOTE_A5,4, NOTE_A5,8, NOTE_AS5,8, NOTE_A5,8, NOTE_G5,8, 148 | NOTE_F5,4, NOTE_D5,4, NOTE_C5,8, NOTE_C5,8, 149 | NOTE_D5,4, NOTE_G5,4, NOTE_E5,4, 150 | NOTE_F5,2, NOTE_C5,4, 151 | NOTE_F5,4, NOTE_F5,4, NOTE_F5,4, 152 | NOTE_E5,2, NOTE_E5,4, 153 | NOTE_F5,4, NOTE_E5,4, NOTE_D5,4, 154 | 155 | NOTE_C5,2, NOTE_A5,4,//36 156 | NOTE_AS5,4, NOTE_A5,4, NOTE_G5,4, 157 | NOTE_C6,4, NOTE_C5,4, NOTE_C5,8, NOTE_C5,8, 158 | NOTE_D5,4, NOTE_G5,4, NOTE_E5,4, 159 | NOTE_F5,2, NOTE_C5,4, 160 | NOTE_F5,4, NOTE_F5,8, NOTE_G5,8, NOTE_F5,8, NOTE_E5,8, 161 | NOTE_D5,4, NOTE_D5,4, NOTE_D5,4, 162 | NOTE_G5,4, NOTE_G5,8, NOTE_A5,8, NOTE_G5,8, NOTE_F5,8, 163 | NOTE_E5,4, NOTE_C5,4, NOTE_C5,4, 164 | 165 | NOTE_A5,4, NOTE_A5,8, NOTE_AS5,8, NOTE_A5,8, NOTE_G5,8,//45 166 | NOTE_F5,4, NOTE_D5,4, NOTE_C5,8, NOTE_C5,8, 167 | NOTE_D5,4, NOTE_G5,4, NOTE_E5,4, 168 | NOTE_F5,2, NOTE_C5,4, 169 | NOTE_F5,4, NOTE_F5,8, NOTE_G5,8, NOTE_F5,8, NOTE_E5,8, 170 | NOTE_D5,4, NOTE_D5,4, NOTE_D5,4, 171 | NOTE_G5,4, NOTE_G5,8, NOTE_A5,8, NOTE_G5,8, NOTE_F5,8, 172 | NOTE_E5,4, NOTE_C5,4, NOTE_C5,4, 173 | 174 | NOTE_A5,4, NOTE_A5,8, NOTE_AS5,8, NOTE_A5,8, NOTE_G5,8, //53 175 | NOTE_F5,4, NOTE_D5,4, NOTE_C5,8, NOTE_C5,8, 176 | NOTE_D5,4, NOTE_G5,4, NOTE_E5,4, 177 | NOTE_F5,2, REST,4 178 | }; 179 | 180 | // sizeof gives the number of bytes, each int value is composed of two bytes (16 bits) 181 | // there are two values per note (pitch and duration), so for each note there are four bytes 182 | int notes = sizeof(melody) / sizeof(melody[0]) / 2; 183 | 184 | // this calculates the duration of a whole note in ms 185 | int wholenote = (60000 * 4) / tempo; 186 | 187 | int divider = 0, noteDuration = 0; 188 | 189 | void setup() { 190 | // iterate over the notes of the melody. 191 | // Remember, the array is twice the number of notes (notes + durations) 192 | for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) { 193 | 194 | // calculates the duration of each note 195 | divider = melody[thisNote + 1]; 196 | if (divider > 0) { 197 | // regular note, just proceed 198 | noteDuration = (wholenote) / divider; 199 | } else if (divider < 0) { 200 | // dotted notes are represented with negative durations!! 201 | noteDuration = (wholenote) / abs(divider); 202 | noteDuration *= 1.5; // increases the duration in half for dotted notes 203 | } 204 | 205 | // we only play the note for 90% of the duration, leaving 10% as a pause 206 | tone(buzzer, melody[thisNote], noteDuration * 0.9); 207 | 208 | // Wait for the specief duration before playing the next note. 209 | delay(noteDuration); 210 | 211 | // stop the waveform generation before the next note. 212 | noTone(buzzer); 213 | } 214 | } 215 | 216 | void loop() { 217 | // no need to repeat the melody. 218 | } 219 | -------------------------------------------------------------------------------- /pulodagaita/pulodagaita.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Pulo da Gaita - O Auto da Compadecida 3 | Connect a piezo buzzer or speaker to pin 11 or select a new pin. 4 | More songs available at https://github.com/robsoncouto/arduino-songs 5 | 6 | Robson Couto, 2019 7 | */ 8 | 9 | #define NOTE_B0 31 10 | #define NOTE_C1 33 11 | #define NOTE_CS1 35 12 | #define NOTE_D1 37 13 | #define NOTE_DS1 39 14 | #define NOTE_E1 41 15 | #define NOTE_F1 44 16 | #define NOTE_FS1 46 17 | #define NOTE_G1 49 18 | #define NOTE_GS1 52 19 | #define NOTE_A1 55 20 | #define NOTE_AS1 58 21 | #define NOTE_B1 62 22 | #define NOTE_C2 65 23 | #define NOTE_CS2 69 24 | #define NOTE_D2 73 25 | #define NOTE_DS2 78 26 | #define NOTE_E2 82 27 | #define NOTE_F2 87 28 | #define NOTE_FS2 93 29 | #define NOTE_G2 98 30 | #define NOTE_GS2 104 31 | #define NOTE_A2 110 32 | #define NOTE_AS2 117 33 | #define NOTE_B2 123 34 | #define NOTE_C3 131 35 | #define NOTE_CS3 139 36 | #define NOTE_D3 147 37 | #define NOTE_DS3 156 38 | #define NOTE_E3 165 39 | #define NOTE_F3 175 40 | #define NOTE_FS3 185 41 | #define NOTE_G3 196 42 | #define NOTE_GS3 208 43 | #define NOTE_A3 220 44 | #define NOTE_AS3 233 45 | #define NOTE_B3 247 46 | #define NOTE_C4 262 47 | #define NOTE_CS4 277 48 | #define NOTE_D4 294 49 | #define NOTE_DS4 311 50 | #define NOTE_E4 330 51 | #define NOTE_F4 349 52 | #define NOTE_FS4 370 53 | #define NOTE_G4 392 54 | #define NOTE_GS4 415 55 | #define NOTE_A4 440 56 | #define NOTE_AS4 466 57 | #define NOTE_B4 494 58 | #define NOTE_C5 523 59 | #define NOTE_CS5 554 60 | #define NOTE_D5 587 61 | #define NOTE_DS5 622 62 | #define NOTE_E5 659 63 | #define NOTE_F5 698 64 | #define NOTE_FS5 740 65 | #define NOTE_G5 784 66 | #define NOTE_GS5 831 67 | #define NOTE_A5 880 68 | #define NOTE_AS5 932 69 | #define NOTE_B5 988 70 | #define NOTE_C6 1047 71 | #define NOTE_CS6 1109 72 | #define NOTE_D6 1175 73 | #define NOTE_DS6 1245 74 | #define NOTE_E6 1319 75 | #define NOTE_F6 1397 76 | #define NOTE_FS6 1480 77 | #define NOTE_G6 1568 78 | #define NOTE_GS6 1661 79 | #define NOTE_A6 1760 80 | #define NOTE_AS6 1865 81 | #define NOTE_B6 1976 82 | #define NOTE_C7 2093 83 | #define NOTE_CS7 2217 84 | #define NOTE_D7 2349 85 | #define NOTE_DS7 2489 86 | #define NOTE_E7 2637 87 | #define NOTE_F7 2794 88 | #define NOTE_FS7 2960 89 | #define NOTE_G7 3136 90 | #define NOTE_GS7 3322 91 | #define NOTE_A7 3520 92 | #define NOTE_AS7 3729 93 | #define NOTE_B7 3951 94 | #define NOTE_C8 4186 95 | #define NOTE_CS8 4435 96 | #define NOTE_D8 4699 97 | #define NOTE_DS8 4978 98 | #define REST 0 99 | 100 | 101 | // change this to make the song slower or faster 102 | int tempo = 100; 103 | 104 | // change this to whichever pin you want to use 105 | int buzzer = 11; 106 | 107 | // notes of the moledy followed by the duration. 108 | // a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on 109 | // !!negative numbers are used to represent dotted notes, 110 | // so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!! 111 | int melody[] = { 112 | 113 | // Pulo da gaita - Auto da Compadecida 114 | // Score available at https://musescore.com/user/196039/scores/250206 115 | 116 | NOTE_C5,4, NOTE_G4,8, NOTE_AS4,4, NOTE_A4,8, 117 | NOTE_G4,16, NOTE_C4,8, NOTE_C4,16, NOTE_G4,16, NOTE_G4,8, NOTE_G4,16, 118 | NOTE_C5,4, NOTE_G4,8, NOTE_AS4,4, NOTE_A4,8, 119 | NOTE_G4,2, 120 | 121 | NOTE_C5,4, NOTE_G4,8, NOTE_AS4,4, NOTE_A4,8, 122 | NOTE_G4,16, NOTE_C4,8, NOTE_C4,16, NOTE_G4,16, NOTE_G4,8, NOTE_G4,16, 123 | NOTE_F4,8, NOTE_E4,8, NOTE_D4,8, NOTE_C4,8, 124 | NOTE_C4,2, 125 | 126 | NOTE_C5,4, NOTE_G4,8, NOTE_AS4,4, NOTE_A4,8, 127 | NOTE_G4,16, NOTE_C4,8, NOTE_C4,16, NOTE_G4,16, NOTE_G4,8, NOTE_G4,16, 128 | NOTE_C5,4, NOTE_G4,8, NOTE_AS4,4, NOTE_A4,8, 129 | NOTE_G4,2, 130 | 131 | NOTE_C5,4, NOTE_G4,8, NOTE_AS4,4, NOTE_A4,8, 132 | NOTE_G4,16, NOTE_C4,8, NOTE_C4,16, NOTE_G4,16, NOTE_G4,8, NOTE_G4,16, 133 | NOTE_F4,8, NOTE_E4,8, NOTE_D4,8, NOTE_C4,8, 134 | NOTE_C4,16, NOTE_D5,8, NOTE_D5,16, NOTE_D5,16, NOTE_D5,8, NOTE_D5,16, 135 | 136 | NOTE_D5,16, NOTE_D5,8, NOTE_D5,16, NOTE_C5,8, NOTE_E5,-8, 137 | NOTE_C5,8, NOTE_C5,16, NOTE_E5,16, NOTE_E5,8, NOTE_C5,16, 138 | NOTE_F5,8, NOTE_D5,8, NOTE_D5,8, NOTE_E5,-8, 139 | NOTE_C5,8, NOTE_D5,16, NOTE_E5,16, NOTE_D5,8, NOTE_C5,16, 140 | 141 | NOTE_F5,8, NOTE_F5,8, NOTE_A5,8, NOTE_G5,-8,//21 142 | NOTE_G5,8, NOTE_C5,16, NOTE_C5,16, NOTE_C5,8, NOTE_C5,16, 143 | NOTE_F5,-8, NOTE_E5,16, NOTE_D5,8, NOTE_C5,4, 144 | NOTE_C5,16, NOTE_C5,16, NOTE_C5,16, NOTE_C5,16, 145 | 146 | NOTE_F5,8, NOTE_F5,16, NOTE_A5,8, NOTE_G5,-8,//25 147 | NOTE_G5,8, NOTE_C5,16, NOTE_C5,16, NOTE_C5,8, NOTE_C5,16, 148 | NOTE_F5,16, NOTE_E5,8, NOTE_D5,16, NOTE_C5,8, NOTE_E5,-8, 149 | NOTE_C5,8, NOTE_D5,16, NOTE_E5,16, NOTE_D5,8, NOTE_C5,16, 150 | 151 | NOTE_F5,8, NOTE_F5,16, NOTE_A5,8, NOTE_G5,-8,//29 152 | NOTE_G5,8, NOTE_C5,16, NOTE_C5,16, NOTE_C5,8, NOTE_C5,16, 153 | NOTE_F5,8, NOTE_E5,16, NOTE_D5,8, NOTE_C5,8, 154 | NOTE_C5,4, NOTE_G4,8, NOTE_AS4,4, NOTE_A4,8, 155 | 156 | NOTE_G4,16, NOTE_C4,8, NOTE_C4,16, NOTE_G4,16, NOTE_G4,8, NOTE_G4,16, 157 | NOTE_C5,4, NOTE_G4,8, NOTE_AS4,4, NOTE_A4,8, 158 | NOTE_G4,2, 159 | NOTE_C5,4, NOTE_G4,8, NOTE_AS4,4, NOTE_A4,8, 160 | 161 | NOTE_G4,16, NOTE_C4,8, NOTE_C4,16, NOTE_G4,16, NOTE_G4,8, NOTE_G4,16, 162 | NOTE_F4,8, NOTE_E4,8, NOTE_D4,8, NOTE_C4,-2, 163 | NOTE_C5,4, NOTE_G4,8, NOTE_AS4,4, NOTE_A4,8, 164 | 165 | NOTE_G4,16, NOTE_C4,8, NOTE_C4,16, NOTE_G4,16, NOTE_G4,8, NOTE_G4,16, 166 | NOTE_C5,4, NOTE_G4,8, NOTE_AS4,4, NOTE_A4,8, 167 | NOTE_G4,2, 168 | NOTE_C5,4, NOTE_G4,8, NOTE_AS4,4, NOTE_A4,8, 169 | 170 | NOTE_G4,16, NOTE_C4,8, NOTE_C4,16, NOTE_G4,16, NOTE_G4,8, NOTE_G4,16, 171 | NOTE_F4,8, NOTE_E4,8, NOTE_D4,8, NOTE_C4,-2, 172 | NOTE_C4,16, NOTE_C4,8, NOTE_C4,16, NOTE_E4,16, NOTE_E4,8, NOTE_E4,16, 173 | NOTE_F4,16, NOTE_F4,8, NOTE_F4,16, NOTE_FS4,16, NOTE_FS4,8, NOTE_FS4,16, 174 | 175 | NOTE_G4,8, REST,8, NOTE_AS4,8, NOTE_C5,1, 176 | 177 | 178 | 179 | }; 180 | 181 | // sizeof gives the number of bytes, each int value is composed of two bytes (16 bits) 182 | // there are two values per note (pitch and duration), so for each note there are four bytes 183 | int notes = sizeof(melody) / sizeof(melody[0]) / 2; 184 | 185 | // this calculates the duration of a whole note in ms 186 | int wholenote = (60000 * 4) / tempo; 187 | 188 | int divider = 0, noteDuration = 0; 189 | 190 | void setup() { 191 | // iterate over the notes of the melody. 192 | // Remember, the array is twice the number of notes (notes + durations) 193 | for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) { 194 | 195 | // calculates the duration of each note 196 | divider = melody[thisNote + 1]; 197 | if (divider > 0) { 198 | // regular note, just proceed 199 | noteDuration = (wholenote) / divider; 200 | } else if (divider < 0) { 201 | // dotted notes are represented with negative durations!! 202 | noteDuration = (wholenote) / abs(divider); 203 | noteDuration *= 1.5; // increases the duration in half for dotted notes 204 | } 205 | 206 | // we only play the note for 90% of the duration, leaving 10% as a pause 207 | tone(buzzer, melody[thisNote], noteDuration*0.9); 208 | 209 | // Wait for the specief duration before playing the next note. 210 | delay(noteDuration); 211 | 212 | // stop the waveform generation before the next note. 213 | noTone(buzzer); 214 | } 215 | } 216 | 217 | void loop() { 218 | // no need to repeat the melody. 219 | } 220 | -------------------------------------------------------------------------------- /vampirekiller/vampirekiller.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Vampire Killer - Castlevania series 3 | Connect a piezo buzzer or speaker to pin 11 or select a new pin. 4 | More songs available at https://github.com/robsoncouto/arduino-songs 5 | 6 | Robson Couto, 2019 7 | */ 8 | #define NOTE_B0 31 9 | #define NOTE_C1 33 10 | #define NOTE_CS1 35 11 | #define NOTE_D1 37 12 | #define NOTE_DS1 39 13 | #define NOTE_E1 41 14 | #define NOTE_F1 44 15 | #define NOTE_FS1 46 16 | #define NOTE_G1 49 17 | #define NOTE_GS1 52 18 | #define NOTE_A1 55 19 | #define NOTE_AS1 58 20 | #define NOTE_B1 62 21 | #define NOTE_C2 65 22 | #define NOTE_CS2 69 23 | #define NOTE_D2 73 24 | #define NOTE_DS2 78 25 | #define NOTE_E2 82 26 | #define NOTE_F2 87 27 | #define NOTE_FS2 93 28 | #define NOTE_G2 98 29 | #define NOTE_GS2 104 30 | #define NOTE_A2 110 31 | #define NOTE_AS2 117 32 | #define NOTE_B2 123 33 | #define NOTE_C3 131 34 | #define NOTE_CS3 139 35 | #define NOTE_D3 147 36 | #define NOTE_DS3 156 37 | #define NOTE_E3 165 38 | #define NOTE_F3 175 39 | #define NOTE_FS3 185 40 | #define NOTE_G3 196 41 | #define NOTE_GS3 208 42 | #define NOTE_A3 220 43 | #define NOTE_AS3 233 44 | #define NOTE_B3 247 45 | #define NOTE_C4 262 46 | #define NOTE_CS4 277 47 | #define NOTE_D4 294 48 | #define NOTE_DS4 311 49 | #define NOTE_E4 330 50 | #define NOTE_F4 349 51 | #define NOTE_FS4 370 52 | #define NOTE_G4 392 53 | #define NOTE_GS4 415 54 | #define NOTE_A4 440 55 | #define NOTE_AS4 466 56 | #define NOTE_B4 494 57 | #define NOTE_C5 523 58 | #define NOTE_CS5 554 59 | #define NOTE_D5 587 60 | #define NOTE_DS5 622 61 | #define NOTE_E5 659 62 | #define NOTE_F5 698 63 | #define NOTE_FS5 740 64 | #define NOTE_G5 784 65 | #define NOTE_GS5 831 66 | #define NOTE_A5 880 67 | #define NOTE_AS5 932 68 | #define NOTE_B5 988 69 | #define NOTE_C6 1047 70 | #define NOTE_CS6 1109 71 | #define NOTE_D6 1175 72 | #define NOTE_DS6 1245 73 | #define NOTE_E6 1319 74 | #define NOTE_F6 1397 75 | #define NOTE_FS6 1480 76 | #define NOTE_G6 1568 77 | #define NOTE_GS6 1661 78 | #define NOTE_A6 1760 79 | #define NOTE_AS6 1865 80 | #define NOTE_B6 1976 81 | #define NOTE_C7 2093 82 | #define NOTE_CS7 2217 83 | #define NOTE_D7 2349 84 | #define NOTE_DS7 2489 85 | #define NOTE_E7 2637 86 | #define NOTE_F7 2794 87 | #define NOTE_FS7 2960 88 | #define NOTE_G7 3136 89 | #define NOTE_GS7 3322 90 | #define NOTE_A7 3520 91 | #define NOTE_AS7 3729 92 | #define NOTE_B7 3951 93 | #define NOTE_C8 4186 94 | #define NOTE_CS8 4435 95 | #define NOTE_D8 4699 96 | #define NOTE_DS8 4978 97 | #define REST 0 98 | 99 | 100 | // change this to make the song slower or faster 101 | int tempo = 130; 102 | 103 | // change this to whichever pin you want to use 104 | int buzzer = 11; 105 | 106 | // notes of the moledy followed by the duration. 107 | // a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on 108 | // !!negative numbers are used to represent dotted notes, 109 | // so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!! 110 | int melody[] = { 111 | 112 | // Vamire Killer, from castlevania 113 | // Score available at https://musescore.com/user/28972071/scores/5425616 114 | // Theme starts at measure 6 115 | 116 | NOTE_E5,16, NOTE_E5,8, NOTE_D5,16, REST,16, NOTE_CS5,-4, NOTE_E4,8, NOTE_FS4,16, NOTE_G4,16, NOTE_A4,16, 117 | 118 | NOTE_B4,-8, NOTE_E4,-8, NOTE_B4,8, NOTE_A4,16, NOTE_D5,-4, //7 119 | NOTE_E5,16, NOTE_E5,8, NOTE_D5,16, REST,16, NOTE_CS5,-4, NOTE_E4,8, NOTE_FS4,16, NOTE_G4,16, NOTE_A4,16, 120 | NOTE_B4,-8, NOTE_E4,-8, NOTE_B4,8, NOTE_A4,16, NOTE_D4,-4, 121 | REST,8, NOTE_E5,8, REST,16, NOTE_B5,16, REST,8, NOTE_AS5,16, NOTE_B5,16, NOTE_AS5,16, NOTE_G5,16, REST,4, 122 | 123 | NOTE_B5,8, NOTE_B5,16, NOTE_AS5,16, REST,16, NOTE_AS5,16, NOTE_A5,16, REST,16, NOTE_B5,16, NOTE_G5,16, NOTE_B5,16, NOTE_AS5,16, REST,16, NOTE_B5,16, NOTE_A5,16, NOTE_G5,16,//11 124 | REST,8, NOTE_E5,8, REST,16, NOTE_B5,16, REST,8, NOTE_AS5,16, NOTE_B5,16, NOTE_AS5,16, NOTE_G5,16, REST,4, 125 | NOTE_B5,8, NOTE_B5,16, NOTE_AS5,16, REST,16, NOTE_AS5,16, NOTE_A5,16, REST,16, NOTE_B5,16, NOTE_G5,16, NOTE_B5,16, NOTE_AS5,16, REST,16, NOTE_B5,16, NOTE_A5,16, NOTE_G5,16, 126 | 127 | NOTE_DS4,-8, NOTE_FS4,-8, NOTE_C5,8, NOTE_B4,-8, NOTE_G4,-8, NOTE_E4,8, //14 128 | NOTE_DS4,-8, NOTE_FS4,-8, NOTE_C5,8, NOTE_B4,-8, NOTE_G4,-8, REST,8, 129 | NOTE_DS4,-8, NOTE_FS4,-8, NOTE_C5,8, NOTE_B4,-8, NOTE_G4,-8, NOTE_E4,8, 130 | NOTE_DS4,-8, NOTE_FS4,-8, NOTE_C5,8, NOTE_B4,-8, NOTE_CS5,-8, NOTE_DS5,8, 131 | 132 | NOTE_E5,16, NOTE_E5,16, NOTE_E4,16, NOTE_E4,-2,//18 133 | NOTE_C4,8, NOTE_C4,8, NOTE_E4,16, NOTE_G4,-8, NOTE_D4,8, NOTE_D4,8, NOTE_FS4,16, NOTE_A4,-8, 134 | NOTE_E5,16, NOTE_E5,16, NOTE_E4,16, NOTE_E4,-2, 135 | NOTE_C4,8, NOTE_C4,8, NOTE_E4,16, NOTE_G4,-8, NOTE_D4,8, NOTE_D4,8, NOTE_B3,16, NOTE_D4,-8, 136 | 137 | //repeats a second time 138 | 139 | NOTE_E5,16, NOTE_E5,8, NOTE_D5,16, REST,16, NOTE_CS5,-4, NOTE_E4,8, NOTE_FS4,16, NOTE_G4,16, NOTE_A4,16, 140 | 141 | NOTE_B4,-8, NOTE_E4,-8, NOTE_B4,8, NOTE_A4,16, NOTE_D5,-4, //7 142 | NOTE_E5,16, NOTE_E5,8, NOTE_D5,16, REST,16, NOTE_CS5,-4, NOTE_E4,8, NOTE_FS4,16, NOTE_G4,16, NOTE_A4,16, 143 | NOTE_B4,-8, NOTE_E4,-8, NOTE_B4,8, NOTE_A4,16, NOTE_D4,-4, 144 | REST,8, NOTE_E5,8, REST,16, NOTE_B5,16, REST,8, NOTE_AS5,16, NOTE_B5,16, NOTE_AS5,16, NOTE_G5,16, REST,4, 145 | 146 | NOTE_B5,8, NOTE_B5,16, NOTE_AS5,16, REST,16, NOTE_AS5,16, NOTE_A5,16, REST,16, NOTE_B5,16, NOTE_G5,16, NOTE_B5,16, NOTE_AS5,16, REST,16, NOTE_B5,16, NOTE_A5,16, NOTE_G5,16,//11 147 | REST,8, NOTE_E5,8, REST,16, NOTE_B5,16, REST,8, NOTE_AS5,16, NOTE_B5,16, NOTE_AS5,16, NOTE_G5,16, REST,4, 148 | NOTE_B5,8, NOTE_B5,16, NOTE_AS5,16, REST,16, NOTE_AS5,16, NOTE_A5,16, REST,16, NOTE_B5,16, NOTE_G5,16, NOTE_B5,16, NOTE_AS5,16, REST,16, NOTE_B5,16, NOTE_A5,16, NOTE_G5,16, 149 | 150 | NOTE_DS4,-8, NOTE_FS4,-8, NOTE_C5,8, NOTE_B4,-8, NOTE_G4,-8, NOTE_E4,8, //14 151 | NOTE_DS4,-8, NOTE_FS4,-8, NOTE_C5,8, NOTE_B4,-8, NOTE_G4,-8, REST,8, 152 | NOTE_DS4,-8, NOTE_FS4,-8, NOTE_C5,8, NOTE_B4,-8, NOTE_G4,-8, NOTE_E4,8, 153 | NOTE_DS4,-8, NOTE_FS4,-8, NOTE_C5,8, NOTE_B4,-8, NOTE_CS5,-8, NOTE_DS5,8, 154 | 155 | NOTE_E5,16, NOTE_E5,16, NOTE_E4,16, NOTE_E4,-2,//18 156 | NOTE_C4,8, NOTE_C4,8, NOTE_E4,16, NOTE_G4,-8, NOTE_D4,8, NOTE_D4,8, NOTE_FS4,16, NOTE_A4,-8, 157 | NOTE_E5,16, NOTE_E5,16, NOTE_E4,16, NOTE_E4,-2, 158 | NOTE_C4,8, NOTE_C4,8, NOTE_E4,16, NOTE_G4,-8, NOTE_D4,8, NOTE_D4,8, NOTE_B3,16, NOTE_D4,-8, 159 | 160 | }; 161 | 162 | // sizeof gives the number of bytes, each int value is composed of two bytes (16 bits) 163 | // there are two values per note (pitch and duration), so for each note there are four bytes 164 | int notes = sizeof(melody) / sizeof(melody[0]) / 2; 165 | 166 | // this calculates the duration of a whole note in ms 167 | int wholenote = (60000 * 4) / tempo; 168 | 169 | int divider = 0, noteDuration = 0; 170 | 171 | void setup() { 172 | // iterate over the notes of the melody. 173 | // Remember, the array is twice the number of notes (notes + durations) 174 | for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) { 175 | 176 | // calculates the duration of each note 177 | divider = melody[thisNote + 1]; 178 | if (divider > 0) { 179 | // regular note, just proceed 180 | noteDuration = (wholenote) / divider; 181 | } else if (divider < 0) { 182 | // dotted notes are represented with negative durations!! 183 | noteDuration = (wholenote) / abs(divider); 184 | noteDuration *= 1.5; // increases the duration in half for dotted notes 185 | } 186 | 187 | // we only play the note for 90% of the duration, leaving 10% as a pause 188 | tone(buzzer, melody[thisNote], noteDuration * 0.9); 189 | 190 | // Wait for the specief duration before playing the next note. 191 | delay(noteDuration); 192 | 193 | // stop the waveform generation before the next note. 194 | noTone(buzzer); 195 | } 196 | } 197 | 198 | void loop() { 199 | // no need to repeat the melody. 200 | } 201 | -------------------------------------------------------------------------------- /thebadinerie/badinerie.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Bach - Badinerie 3 | Connect a piezo buzzer or speaker to pin 11 or select a new pin. 4 | More songs available at https://github.com/robsoncouto/arduino-songs 5 | 6 | Robson Couto, 2019 7 | Juan (gdlost), 2020 8 | 9 | Note (gdlost): I've transcripted from music sheet (https://toplayalong.com/wp-content/uploads/2016/01/253-bach-badinerie-orchestral-suite-no-2-flute.png) 10 | to code, the song needs some fixes, because, in some parts sounds awful XD. 11 | */ 12 | 13 | #define NOTE_B0 31 14 | #define NOTE_C1 33 15 | #define NOTE_CS1 35 16 | #define NOTE_D1 37 17 | #define NOTE_DS1 39 18 | #define NOTE_E1 41 19 | #define NOTE_F1 44 20 | #define NOTE_FS1 46 21 | #define NOTE_G1 49 22 | #define NOTE_GS1 52 23 | #define NOTE_A1 55 24 | #define NOTE_AS1 58 25 | #define NOTE_B1 62 26 | #define NOTE_C2 65 27 | #define NOTE_CS2 69 28 | #define NOTE_D2 73 29 | #define NOTE_DS2 78 30 | #define NOTE_E2 82 31 | #define NOTE_F2 87 32 | #define NOTE_FS2 93 33 | #define NOTE_G2 98 34 | #define NOTE_GS2 104 35 | #define NOTE_A2 110 36 | #define NOTE_AS2 117 37 | #define NOTE_B2 123 38 | #define NOTE_C3 131 39 | #define NOTE_CS3 139 40 | #define NOTE_D3 147 41 | #define NOTE_DS3 156 42 | #define NOTE_E3 165 43 | #define NOTE_F3 175 44 | #define NOTE_FS3 185 45 | #define NOTE_G3 196 46 | #define NOTE_GS3 208 47 | #define NOTE_A3 220 48 | #define NOTE_AS3 233 49 | #define NOTE_B3 247 50 | #define NOTE_C4 262 51 | #define NOTE_CS4 277 52 | #define NOTE_D4 294 53 | #define NOTE_DS4 311 54 | #define NOTE_E4 330 55 | #define NOTE_F4 349 56 | #define NOTE_FS4 370 57 | #define NOTE_G4 392 58 | #define NOTE_GS4 415 59 | #define NOTE_A4 440 60 | #define NOTE_AS4 466 61 | #define NOTE_B4 494 62 | #define NOTE_C5 523 63 | #define NOTE_CS5 554 64 | #define NOTE_D5 587 65 | #define NOTE_DS5 622 66 | #define NOTE_E5 659 67 | #define NOTE_F5 698 68 | #define NOTE_FS5 740 69 | #define NOTE_G5 784 70 | #define NOTE_GS5 831 71 | #define NOTE_A5 880 72 | #define NOTE_AS5 932 73 | #define NOTE_B5 988 74 | #define NOTE_C6 1047 75 | #define NOTE_CS6 1109 76 | #define NOTE_D6 1175 77 | #define NOTE_DS6 1245 78 | #define NOTE_E6 1319 79 | #define NOTE_F6 1397 80 | #define NOTE_FS6 1480 81 | #define NOTE_G6 1568 82 | #define NOTE_GS6 1661 83 | #define NOTE_A6 1760 84 | #define NOTE_AS6 1865 85 | #define NOTE_B6 1976 86 | #define NOTE_C7 2093 87 | #define NOTE_CS7 2217 88 | #define NOTE_D7 2349 89 | #define NOTE_DS7 2489 90 | #define NOTE_E7 2637 91 | #define NOTE_F7 2794 92 | #define NOTE_FS7 2960 93 | #define NOTE_G7 3136 94 | #define NOTE_GS7 3322 95 | #define NOTE_A7 3520 96 | #define NOTE_AS7 3729 97 | #define NOTE_B7 3951 98 | #define NOTE_C8 4186 99 | #define NOTE_CS8 4435 100 | #define NOTE_D8 4699 101 | #define NOTE_DS8 4978 102 | #define REST 0 103 | 104 | 105 | // change this to make the song slower or faster 106 | int tempo = 120; 107 | 108 | // change this to whichever pin you want to use 109 | int buzzer = 11; 110 | 111 | // notes of the moledy followed by the duration. 112 | // a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on 113 | // !!negative numbers are used to represent dotted notes, 114 | // so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!! 115 | int melody[] = { 116 | /* 117 | * C D E F G A B 118 | * DO RE MI FA SOL LA SI */ 119 | // Badinerie 120 | NOTE_B5,-8, NOTE_D6,16, NOTE_B5,16, 121 | NOTE_FS5,-8, NOTE_B5,16, NOTE_FS5,16, NOTE_D5,-8, NOTE_FS5,16, NOTE_D5,16, 122 | NOTE_B4,4,NOTE_F4,16, NOTE_B4,16, NOTE_D5,16, NOTE_B4,16, 123 | NOTE_CS5,16, NOTE_B4,16, NOTE_CS5,16, NOTE_B4,16, NOTE_AS4,16, NOTE_CS5,16, NOTE_E5,16, NOTE_CS5,16, 124 | NOTE_D5,8, NOTE_B4,8, NOTE_B5,-8, NOTE_D6,16, NOTE_B5,16, 125 | NOTE_FS5,-8, NOTE_B5,16, NOTE_FS5,16, NOTE_D5,-8, NOTE_FS5,16, NOTE_D5,16, 126 | //6 127 | NOTE_B4,4, NOTE_D5,16, NOTE_CS5,-16, NOTE_D5,-8, 128 | NOTE_D5,16, NOTE_CS5,-16, NOTE_D5,-8, NOTE_B5,-8, NOTE_D5,-8, 129 | NOTE_D5,8, NOTE_CS5,-8, NOTE_FS5,-16, /*MI#*/ NOTE_F5,16, NOTE_FS5,-8, 130 | NOTE_FS5,-16, /* MI#??*/NOTE_F5,16, NOTE_FS5,-8, NOTE_D6,-8, NOTE_FS5,-8, 131 | NOTE_FS5,8, /*MI#*/ NOTE_F5,8, NOTE_CS5,16, NOTE_FS5,16, NOTE_A5,16, NOTE_FS5,16, 132 | NOTE_GS5,16, NOTE_FS5,16, NOTE_GS5,16, NOTE_FS5,16, NOTE_F5,16, NOTE_G5,16, NOTE_B5,16, NOTE_G5,16, 133 | //12 134 | NOTE_A5,16, NOTE_GS5,16, NOTE_A5,16, NOTE_G5,16, NOTE_F5,16, NOTE_A5,16, NOTE_FS5,16, NOTE_F5,16, 135 | NOTE_FS5,16, NOTE_B5,16, NOTE_FS5,16, NOTE_F5,16, NOTE_FS5,16, NOTE_C6,16, NOTE_FS5,16, NOTE_E5,16, 136 | NOTE_FS5,16, NOTE_D6,16, NOTE_FS5,16, NOTE_F5,16, NOTE_FS5,16, NOTE_D6,16, NOTE_C6,16, NOTE_B5,16, 137 | NOTE_C6,16, NOTE_A5,16, NOTE_GS5,16, NOTE_FS5,16, NOTE_A5,8, NOTE_G5,8, 138 | NOTE_FS5,4, REST,4, NOTE_FS5,-8, NOTE_A5,16, NOTE_FS5,16, 139 | //18 140 | NOTE_CS5,-4, NOTE_FS5,16, NOTE_CS5,16, NOTE_A4,-8, NOTE_CS5,16, NOTE_A4,16, 141 | NOTE_F4,4, NOTE_C5,8, NOTE_B4,8, 142 | NOTE_E5,8, NOTE_DS5,16, NOTE_FS5,16, NOTE_A5,8, NOTE_GS5,16, NOTE_FS5,16, 143 | NOTE_GS5,8, NOTE_D5,8, NOTE_GS5,-8, NOTE_B5,16, NOTE_GS5,8, 144 | NOTE_E5,-8, NOTE_GS5,16, NOTE_E5,16, NOTE_CS5,-8, NOTE_E5,16, NOTE_CS5,16, 145 | NOTE_A4,4, NOTE_A4,16, NOTE_D5,16, NOTE_FS5,16, NOTE_D5,16, 146 | //24 147 | NOTE_E5,16, NOTE_D5,16, NOTE_E5,16, NOTE_D5,16, NOTE_CS5,16, NOTE_E5,16, NOTE_G5,16, NOTE_E5,16, 148 | NOTE_FS5,16, NOTE_E5,16, NOTE_FS5,16, NOTE_E5,16, NOTE_D5,16, NOTE_FS5,16, NOTE_D5,16, NOTE_CS5,16, 149 | NOTE_D5,16, NOTE_G5,16, NOTE_D5,16, NOTE_CS5,16, NOTE_D5,16, NOTE_A5,16, NOTE_D5,16, NOTE_CS5,16, 150 | NOTE_D5,16, NOTE_B5,16, NOTE_D5,16, NOTE_CS5,16, NOTE_D5,16, NOTE_B5,16, NOTE_A5,16, NOTE_G5,16, 151 | NOTE_A5,16, NOTE_FS5,16, NOTE_E5,16, NOTE_D5,16, NOTE_FS5,8, NOTE_E5,16, 152 | //29 153 | NOTE_D5,4, NOTE_FS5,16, NOTE_E5,16, NOTE_FS5,-8, 154 | NOTE_FS5,16, NOTE_E5,16, NOTE_FS5,-8, NOTE_D6,-8, NOTE_FS5,-8, 155 | NOTE_FS5,8, NOTE_E5,8, NOTE_E5,16, NOTE_D5,16, NOTE_E5,-8, 156 | NOTE_E5,16, NOTE_D5,16, NOTE_E5,-8, NOTE_D6,-8, NOTE_E5,-8, 157 | NOTE_E5,8, NOTE_D5,8, NOTE_B5,-8, NOTE_D6,16, NOTE_B5,16, 158 | NOTE_B5,8, NOTE_G5,4, NOTE_G5,4, NOTE_B5,32, NOTE_A5,32, NOTE_G5,32, NOTE_FS5,32, 159 | //35 160 | NOTE_E5,4, NOTE_E5,8, NOTE_G5,32, NOTE_FS5,32, NOTE_E5,32, NOTE_D5,32, 161 | NOTE_C5,16, NOTE_E5,16, NOTE_G5,16, NOTE_E5,16, NOTE_CS5,16, NOTE_B4,16, NOTE_CS5,16, NOTE_A4,16, 162 | NOTE_AS4,-8, NOTE_A4,-8, NOTE_G4,8, NOTE_F4,8, 163 | NOTE_A4,8, NOTE_AS4,16, NOTE_CS5,16, NOTE_E5,8, NOTE_D5,16, NOTE_CS5,16, 164 | //39 165 | NOTE_D5,8, NOTE_B4,32, NOTE_CS5,32, NOTE_D5,32, NOTE_E5,32, NOTE_FS5,8, NOTE_D5,16, NOTE_FS5,16, 166 | NOTE_B5,8, NOTE_FS5,8, NOTE_E5,16, NOTE_D5,16, NOTE_CS5,16, NOTE_D5,16, 167 | NOTE_CS5,8, NOTE_B4,4 168 | }; 169 | 170 | // sizeof gives the number of bytes, each int value is composed of two bytes (16 bits) 171 | // there are two values per note (pitch and duration), so for each note there are four bytes 172 | int notes = sizeof(melody) / sizeof(melody[0]) / 2; 173 | 174 | // this calculates the duration of a whole note in ms 175 | int wholenote = (60000 * 4) / tempo; 176 | 177 | int divider = 0, noteDuration = 0; 178 | 179 | void setup() { 180 | // iterate over the notes of the melody. 181 | // Remember, the array is twice the number of notes (notes + durations) 182 | for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) { 183 | 184 | // calculates the duration of each note 185 | divider = melody[thisNote + 1]; 186 | if (divider > 0) { 187 | // regular note, just proceed 188 | noteDuration = (wholenote) / divider; 189 | } else if (divider < 0) { 190 | // dotted notes are represented with negative durations!! 191 | noteDuration = (wholenote) / abs(divider); 192 | noteDuration *= 1.5; // increases the duration in half for dotted notes 193 | } 194 | 195 | // we only play the note for 90% of the duration, leaving 10% as a pause 196 | tone(buzzer, melody[thisNote], noteDuration * 0.9); 197 | 198 | // Wait for the specief duration before playing the next note. 199 | delay(noteDuration); 200 | 201 | // stop the waveform generation before the next note. 202 | noTone(buzzer); 203 | } 204 | } 205 | 206 | void loop() { 207 | // no need to repeat the melody. 208 | } 209 | -------------------------------------------------------------------------------- /miichannel/miichannel.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Mii Channel's theme 3 | Connect a piezo buzzer or speaker to pin 11 or select a new pin. 4 | More songs available at https://github.com/robsoncouto/arduino-songs 5 | 6 | Robson Couto, 2019 7 | */ 8 | 9 | #define NOTE_B0 31 10 | #define NOTE_C1 33 11 | #define NOTE_CS1 35 12 | #define NOTE_D1 37 13 | #define NOTE_DS1 39 14 | #define NOTE_E1 41 15 | #define NOTE_F1 44 16 | #define NOTE_FS1 46 17 | #define NOTE_G1 49 18 | #define NOTE_GS1 52 19 | #define NOTE_A1 55 20 | #define NOTE_AS1 58 21 | #define NOTE_B1 62 22 | #define NOTE_C2 65 23 | #define NOTE_CS2 69 24 | #define NOTE_D2 73 25 | #define NOTE_DS2 78 26 | #define NOTE_E2 82 27 | #define NOTE_F2 87 28 | #define NOTE_FS2 93 29 | #define NOTE_G2 98 30 | #define NOTE_GS2 104 31 | #define NOTE_A2 110 32 | #define NOTE_AS2 117 33 | #define NOTE_B2 123 34 | #define NOTE_C3 131 35 | #define NOTE_CS3 139 36 | #define NOTE_D3 147 37 | #define NOTE_DS3 156 38 | #define NOTE_E3 165 39 | #define NOTE_F3 175 40 | #define NOTE_FS3 185 41 | #define NOTE_G3 196 42 | #define NOTE_GS3 208 43 | #define NOTE_A3 220 44 | #define NOTE_AS3 233 45 | #define NOTE_B3 247 46 | #define NOTE_C4 262 47 | #define NOTE_CS4 277 48 | #define NOTE_D4 294 49 | #define NOTE_DS4 311 50 | #define NOTE_E4 330 51 | #define NOTE_F4 349 52 | #define NOTE_FS4 370 53 | #define NOTE_G4 392 54 | #define NOTE_GS4 415 55 | #define NOTE_A4 440 56 | #define NOTE_AS4 466 57 | #define NOTE_B4 494 58 | #define NOTE_C5 523 59 | #define NOTE_CS5 554 60 | #define NOTE_D5 587 61 | #define NOTE_DS5 622 62 | #define NOTE_E5 659 63 | #define NOTE_F5 698 64 | #define NOTE_FS5 740 65 | #define NOTE_G5 784 66 | #define NOTE_GS5 831 67 | #define NOTE_A5 880 68 | #define NOTE_AS5 932 69 | #define NOTE_B5 988 70 | #define NOTE_C6 1047 71 | #define NOTE_CS6 1109 72 | #define NOTE_D6 1175 73 | #define NOTE_DS6 1245 74 | #define NOTE_E6 1319 75 | #define NOTE_F6 1397 76 | #define NOTE_FS6 1480 77 | #define NOTE_G6 1568 78 | #define NOTE_GS6 1661 79 | #define NOTE_A6 1760 80 | #define NOTE_AS6 1865 81 | #define NOTE_B6 1976 82 | #define NOTE_C7 2093 83 | #define NOTE_CS7 2217 84 | #define NOTE_D7 2349 85 | #define NOTE_DS7 2489 86 | #define NOTE_E7 2637 87 | #define NOTE_F7 2794 88 | #define NOTE_FS7 2960 89 | #define NOTE_G7 3136 90 | #define NOTE_GS7 3322 91 | #define NOTE_A7 3520 92 | #define NOTE_AS7 3729 93 | #define NOTE_B7 3951 94 | #define NOTE_C8 4186 95 | #define NOTE_CS8 4435 96 | #define NOTE_D8 4699 97 | #define NOTE_DS8 4978 98 | #define REST 0 99 | 100 | 101 | // change this to make the song slower or faster 102 | int tempo = 114; 103 | 104 | // change this to whichever pin you want to use 105 | int buzzer = 11; 106 | 107 | // notes of the moledy followed by the duration. 108 | // a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on 109 | // !!negative numbers are used to represent dotted notes, 110 | // so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!! 111 | int melody[] = { 112 | 113 | // Mii Channel theme 114 | // Score available at https://musescore.com/user/16403456/scores/4984153 115 | // Uploaded by Catalina Andrade 116 | 117 | NOTE_FS4,8, REST,8, NOTE_A4,8, NOTE_CS5,8, REST,8,NOTE_A4,8, REST,8, NOTE_FS4,8, //1 118 | NOTE_D4,8, NOTE_D4,8, NOTE_D4,8, REST,8, REST,4, REST,8, NOTE_CS4,8, 119 | NOTE_D4,8, NOTE_FS4,8, NOTE_A4,8, NOTE_CS5,8, REST,8, NOTE_A4,8, REST,8, NOTE_F4,8, 120 | NOTE_E5,-4, NOTE_DS5,8, NOTE_D5,8, REST,8, REST,4, 121 | 122 | NOTE_GS4,8, REST,8, NOTE_CS5,8, NOTE_FS4,8, REST,8,NOTE_CS5,8, REST,8, NOTE_GS4,8, //5 123 | REST,8, NOTE_CS5,8, NOTE_G4,8, NOTE_FS4,8, REST,8, NOTE_E4,8, REST,8, 124 | NOTE_E4,8, NOTE_E4,8, NOTE_E4,8, REST,8, REST,4, NOTE_E4,8, NOTE_E4,8, 125 | NOTE_E4,8, REST,8, REST,4, NOTE_DS4,8, NOTE_D4,8, 126 | 127 | NOTE_CS4,8, REST,8, NOTE_A4,8, NOTE_CS5,8, REST,8,NOTE_A4,8, REST,8, NOTE_FS4,8, //9 128 | NOTE_D4,8, NOTE_D4,8, NOTE_D4,8, REST,8, NOTE_E5,8, NOTE_E5,8, NOTE_E5,8, REST,8, 129 | REST,8, NOTE_FS4,8, NOTE_A4,8, NOTE_CS5,8, REST,8, NOTE_A4,8, REST,8, NOTE_F4,8, 130 | NOTE_E5,2, NOTE_D5,8, REST,8, REST,4, 131 | 132 | NOTE_B4,8, NOTE_G4,8, NOTE_D4,8, NOTE_CS4,4, NOTE_B4,8, NOTE_G4,8, NOTE_CS4,8, //13 133 | NOTE_A4,8, NOTE_FS4,8, NOTE_C4,8, NOTE_B3,4, NOTE_F4,8, NOTE_D4,8, NOTE_B3,8, 134 | NOTE_E4,8, NOTE_E4,8, NOTE_E4,8, REST,4, REST,4, NOTE_AS4,4, 135 | NOTE_CS5,8, NOTE_D5,8, NOTE_FS5,8, NOTE_A5,8, REST,8, REST,4, 136 | 137 | REST,2, NOTE_A3,4, NOTE_AS3,4, //17 138 | NOTE_A3,-4, NOTE_A3,8, NOTE_A3,2, 139 | REST,4, NOTE_A3,8, NOTE_AS3,8, NOTE_A3,8, NOTE_F4,4, NOTE_C4,8, 140 | NOTE_A3,-4, NOTE_A3,8, NOTE_A3,2, 141 | 142 | REST,2, NOTE_B3,4, NOTE_C4,4, //21 143 | NOTE_CS4,-4, NOTE_C4,8, NOTE_CS4,2, 144 | REST,4, NOTE_CS4,8, NOTE_C4,8, NOTE_CS4,8, NOTE_GS4,4, NOTE_DS4,8, 145 | NOTE_CS4,-4, NOTE_DS4,8, NOTE_B3,1, 146 | 147 | NOTE_E4,4, NOTE_E4,4, NOTE_E4,4, REST,8,//25 148 | 149 | //repeats 1-25 150 | 151 | NOTE_FS4,8, REST,8, NOTE_A4,8, NOTE_CS5,8, REST,8,NOTE_A4,8, REST,8, NOTE_FS4,8, //1 152 | NOTE_D4,8, NOTE_D4,8, NOTE_D4,8, REST,8, REST,4, REST,8, NOTE_CS4,8, 153 | NOTE_D4,8, NOTE_FS4,8, NOTE_A4,8, NOTE_CS5,8, REST,8, NOTE_A4,8, REST,8, NOTE_F4,8, 154 | NOTE_E5,-4, NOTE_DS5,8, NOTE_D5,8, REST,8, REST,4, 155 | 156 | NOTE_GS4,8, REST,8, NOTE_CS5,8, NOTE_FS4,8, REST,8,NOTE_CS5,8, REST,8, NOTE_GS4,8, //5 157 | REST,8, NOTE_CS5,8, NOTE_G4,8, NOTE_FS4,8, REST,8, NOTE_E4,8, REST,8, 158 | NOTE_E4,8, NOTE_E4,8, NOTE_E4,8, REST,8, REST,4, NOTE_E4,8, NOTE_E4,8, 159 | NOTE_E4,8, REST,8, REST,4, NOTE_DS4,8, NOTE_D4,8, 160 | 161 | NOTE_CS4,8, REST,8, NOTE_A4,8, NOTE_CS5,8, REST,8,NOTE_A4,8, REST,8, NOTE_FS4,8, //9 162 | NOTE_D4,8, NOTE_D4,8, NOTE_D4,8, REST,8, NOTE_E5,8, NOTE_E5,8, NOTE_E5,8, REST,8, 163 | REST,8, NOTE_FS4,8, NOTE_A4,8, NOTE_CS5,8, REST,8, NOTE_A4,8, REST,8, NOTE_F4,8, 164 | NOTE_E5,2, NOTE_D5,8, REST,8, REST,4, 165 | 166 | NOTE_B4,8, NOTE_G4,8, NOTE_D4,8, NOTE_CS4,4, NOTE_B4,8, NOTE_G4,8, NOTE_CS4,8, //13 167 | NOTE_A4,8, NOTE_FS4,8, NOTE_C4,8, NOTE_B3,4, NOTE_F4,8, NOTE_D4,8, NOTE_B3,8, 168 | NOTE_E4,8, NOTE_E4,8, NOTE_E4,8, REST,4, REST,4, NOTE_AS4,4, 169 | NOTE_CS5,8, NOTE_D5,8, NOTE_FS5,8, NOTE_A5,8, REST,8, REST,4, 170 | 171 | REST,2, NOTE_A3,4, NOTE_AS3,4, //17 172 | NOTE_A3,-4, NOTE_A3,8, NOTE_A3,2, 173 | REST,4, NOTE_A3,8, NOTE_AS3,8, NOTE_A3,8, NOTE_F4,4, NOTE_C4,8, 174 | NOTE_A3,-4, NOTE_A3,8, NOTE_A3,2, 175 | 176 | REST,2, NOTE_B3,4, NOTE_C4,4, //21 177 | NOTE_CS4,-4, NOTE_C4,8, NOTE_CS4,2, 178 | REST,4, NOTE_CS4,8, NOTE_C4,8, NOTE_CS4,8, NOTE_GS4,4, NOTE_DS4,8, 179 | NOTE_CS4,-4, NOTE_DS4,8, NOTE_B3,1, 180 | 181 | NOTE_E4,4, NOTE_E4,4, NOTE_E4,4, REST,8,//25 182 | 183 | //finishes with 26 184 | //NOTE_FS4,8, REST,8, NOTE_A4,8, NOTE_CS5,8, REST,8, NOTE_A4,8, REST,8, NOTE_FS4,8 185 | 186 | }; 187 | 188 | // sizeof gives the number of bytes, each int value is composed of two bytes (16 bits) 189 | // there are two values per note (pitch and duration), so for each note there are four bytes 190 | int notes = sizeof(melody) / sizeof(melody[0]) / 2; 191 | 192 | // this calculates the duration of a whole note in ms 193 | int wholenote = (60000 * 4) / tempo; 194 | 195 | int divider = 0, noteDuration = 0; 196 | 197 | void setup() { 198 | // iterate over the notes of the melody. 199 | // Remember, the array is twice the number of notes (notes + durations) 200 | for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) { 201 | 202 | // calculates the duration of each note 203 | divider = melody[thisNote + 1]; 204 | if (divider > 0) { 205 | // regular note, just proceed 206 | noteDuration = (wholenote) / divider; 207 | } else if (divider < 0) { 208 | // dotted notes are represented with negative durations!! 209 | noteDuration = (wholenote) / abs(divider); 210 | noteDuration *= 1.5; // increases the duration in half for dotted notes 211 | } 212 | 213 | // we only play the note for 90% of the duration, leaving 10% as a pause 214 | tone(buzzer, melody[thisNote], noteDuration*0.9); 215 | 216 | // Wait for the specief duration before playing the next note. 217 | delay(noteDuration); 218 | 219 | // stop the waveform generation before the next note. 220 | noTone(buzzer); 221 | } 222 | } 223 | 224 | void loop() { 225 | // no need to repeat the melody. 226 | } 227 | -------------------------------------------------------------------------------- /supermariobros/supermariobros.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Super Mario Bros - Overworld theme 3 | Connect a piezo buzzer or speaker to pin 11 or select a new pin. 4 | More songs available at https://github.com/robsoncouto/arduino-songs 5 | 6 | Robson Couto, 2019 7 | */ 8 | 9 | #define NOTE_B0 31 10 | #define NOTE_C1 33 11 | #define NOTE_CS1 35 12 | #define NOTE_D1 37 13 | #define NOTE_DS1 39 14 | #define NOTE_E1 41 15 | #define NOTE_F1 44 16 | #define NOTE_FS1 46 17 | #define NOTE_G1 49 18 | #define NOTE_GS1 52 19 | #define NOTE_A1 55 20 | #define NOTE_AS1 58 21 | #define NOTE_B1 62 22 | #define NOTE_C2 65 23 | #define NOTE_CS2 69 24 | #define NOTE_D2 73 25 | #define NOTE_DS2 78 26 | #define NOTE_E2 82 27 | #define NOTE_F2 87 28 | #define NOTE_FS2 93 29 | #define NOTE_G2 98 30 | #define NOTE_GS2 104 31 | #define NOTE_A2 110 32 | #define NOTE_AS2 117 33 | #define NOTE_B2 123 34 | #define NOTE_C3 131 35 | #define NOTE_CS3 139 36 | #define NOTE_D3 147 37 | #define NOTE_DS3 156 38 | #define NOTE_E3 165 39 | #define NOTE_F3 175 40 | #define NOTE_FS3 185 41 | #define NOTE_G3 196 42 | #define NOTE_GS3 208 43 | #define NOTE_A3 220 44 | #define NOTE_AS3 233 45 | #define NOTE_B3 247 46 | #define NOTE_C4 262 47 | #define NOTE_CS4 277 48 | #define NOTE_D4 294 49 | #define NOTE_DS4 311 50 | #define NOTE_E4 330 51 | #define NOTE_F4 349 52 | #define NOTE_FS4 370 53 | #define NOTE_G4 392 54 | #define NOTE_GS4 415 55 | #define NOTE_A4 440 56 | #define NOTE_AS4 466 57 | #define NOTE_B4 494 58 | #define NOTE_C5 523 59 | #define NOTE_CS5 554 60 | #define NOTE_D5 587 61 | #define NOTE_DS5 622 62 | #define NOTE_E5 659 63 | #define NOTE_F5 698 64 | #define NOTE_FS5 740 65 | #define NOTE_G5 784 66 | #define NOTE_GS5 831 67 | #define NOTE_A5 880 68 | #define NOTE_AS5 932 69 | #define NOTE_B5 988 70 | #define NOTE_C6 1047 71 | #define NOTE_CS6 1109 72 | #define NOTE_D6 1175 73 | #define NOTE_DS6 1245 74 | #define NOTE_E6 1319 75 | #define NOTE_F6 1397 76 | #define NOTE_FS6 1480 77 | #define NOTE_G6 1568 78 | #define NOTE_GS6 1661 79 | #define NOTE_A6 1760 80 | #define NOTE_AS6 1865 81 | #define NOTE_B6 1976 82 | #define NOTE_C7 2093 83 | #define NOTE_CS7 2217 84 | #define NOTE_D7 2349 85 | #define NOTE_DS7 2489 86 | #define NOTE_E7 2637 87 | #define NOTE_F7 2794 88 | #define NOTE_FS7 2960 89 | #define NOTE_G7 3136 90 | #define NOTE_GS7 3322 91 | #define NOTE_A7 3520 92 | #define NOTE_AS7 3729 93 | #define NOTE_B7 3951 94 | #define NOTE_C8 4186 95 | #define NOTE_CS8 4435 96 | #define NOTE_D8 4699 97 | #define NOTE_DS8 4978 98 | #define REST 0 99 | 100 | 101 | // change this to make the song slower or faster 102 | int tempo = 200; 103 | 104 | // change this to whichever pin you want to use 105 | int buzzer = 11; 106 | 107 | 108 | // notes of the moledy followed by the duration. 109 | // a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on 110 | // !!negative numbers are used to represent dotted notes, 111 | // so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!! 112 | int melody[] = { 113 | 114 | // Super Mario Bros theme 115 | // Score available at https://musescore.com/user/2123/scores/2145 116 | // Theme by Koji Kondo 117 | 118 | 119 | NOTE_E5,8, NOTE_E5,8, REST,8, NOTE_E5,8, REST,8, NOTE_C5,8, NOTE_E5,8, //1 120 | NOTE_G5,4, REST,4, NOTE_G4,8, REST,4, 121 | NOTE_C5,-4, NOTE_G4,8, REST,4, NOTE_E4,-4, // 3 122 | NOTE_A4,4, NOTE_B4,4, NOTE_AS4,8, NOTE_A4,4, 123 | NOTE_G4,-8, NOTE_E5,-8, NOTE_G5,-8, NOTE_A5,4, NOTE_F5,8, NOTE_G5,8, 124 | REST,8, NOTE_E5,4,NOTE_C5,8, NOTE_D5,8, NOTE_B4,-4, 125 | NOTE_C5,-4, NOTE_G4,8, REST,4, NOTE_E4,-4, // repeats from 3 126 | NOTE_A4,4, NOTE_B4,4, NOTE_AS4,8, NOTE_A4,4, 127 | NOTE_G4,-8, NOTE_E5,-8, NOTE_G5,-8, NOTE_A5,4, NOTE_F5,8, NOTE_G5,8, 128 | REST,8, NOTE_E5,4,NOTE_C5,8, NOTE_D5,8, NOTE_B4,-4, 129 | 130 | 131 | REST,4, NOTE_G5,8, NOTE_FS5,8, NOTE_F5,8, NOTE_DS5,4, NOTE_E5,8,//7 132 | REST,8, NOTE_GS4,8, NOTE_A4,8, NOTE_C4,8, REST,8, NOTE_A4,8, NOTE_C5,8, NOTE_D5,8, 133 | REST,4, NOTE_DS5,4, REST,8, NOTE_D5,-4, 134 | NOTE_C5,2, REST,2, 135 | 136 | REST,4, NOTE_G5,8, NOTE_FS5,8, NOTE_F5,8, NOTE_DS5,4, NOTE_E5,8,//repeats from 7 137 | REST,8, NOTE_GS4,8, NOTE_A4,8, NOTE_C4,8, REST,8, NOTE_A4,8, NOTE_C5,8, NOTE_D5,8, 138 | REST,4, NOTE_DS5,4, REST,8, NOTE_D5,-4, 139 | NOTE_C5,2, REST,2, 140 | 141 | NOTE_C5,8, NOTE_C5,4, NOTE_C5,8, REST,8, NOTE_C5,8, NOTE_D5,4,//11 142 | NOTE_E5,8, NOTE_C5,4, NOTE_A4,8, NOTE_G4,2, 143 | 144 | NOTE_C5,8, NOTE_C5,4, NOTE_C5,8, REST,8, NOTE_C5,8, NOTE_D5,8, NOTE_E5,8,//13 145 | REST,1, 146 | NOTE_C5,8, NOTE_C5,4, NOTE_C5,8, REST,8, NOTE_C5,8, NOTE_D5,4, 147 | NOTE_E5,8, NOTE_C5,4, NOTE_A4,8, NOTE_G4,2, 148 | NOTE_E5,8, NOTE_E5,8, REST,8, NOTE_E5,8, REST,8, NOTE_C5,8, NOTE_E5,4, 149 | NOTE_G5,4, REST,4, NOTE_G4,4, REST,4, 150 | NOTE_C5,-4, NOTE_G4,8, REST,4, NOTE_E4,-4, // 19 151 | 152 | NOTE_A4,4, NOTE_B4,4, NOTE_AS4,8, NOTE_A4,4, 153 | NOTE_G4,-8, NOTE_E5,-8, NOTE_G5,-8, NOTE_A5,4, NOTE_F5,8, NOTE_G5,8, 154 | REST,8, NOTE_E5,4, NOTE_C5,8, NOTE_D5,8, NOTE_B4,-4, 155 | 156 | NOTE_C5,-4, NOTE_G4,8, REST,4, NOTE_E4,-4, // repeats from 19 157 | NOTE_A4,4, NOTE_B4,4, NOTE_AS4,8, NOTE_A4,4, 158 | NOTE_G4,-8, NOTE_E5,-8, NOTE_G5,-8, NOTE_A5,4, NOTE_F5,8, NOTE_G5,8, 159 | REST,8, NOTE_E5,4, NOTE_C5,8, NOTE_D5,8, NOTE_B4,-4, 160 | 161 | NOTE_E5,8, NOTE_C5,4, NOTE_G4,8, REST,4, NOTE_GS4,4,//23 162 | NOTE_A4,8, NOTE_F5,4, NOTE_F5,8, NOTE_A4,2, 163 | NOTE_D5,-8, NOTE_A5,-8, NOTE_A5,-8, NOTE_A5,-8, NOTE_G5,-8, NOTE_F5,-8, 164 | 165 | NOTE_E5,8, NOTE_C5,4, NOTE_A4,8, NOTE_G4,2, //26 166 | NOTE_E5,8, NOTE_C5,4, NOTE_G4,8, REST,4, NOTE_GS4,4, 167 | NOTE_A4,8, NOTE_F5,4, NOTE_F5,8, NOTE_A4,2, 168 | NOTE_B4,8, NOTE_F5,4, NOTE_F5,8, NOTE_F5,-8, NOTE_E5,-8, NOTE_D5,-8, 169 | NOTE_C5,8, NOTE_E4,4, NOTE_E4,8, NOTE_C4,2, 170 | 171 | NOTE_E5,8, NOTE_C5,4, NOTE_G4,8, REST,4, NOTE_GS4,4,//repeats from 23 172 | NOTE_A4,8, NOTE_F5,4, NOTE_F5,8, NOTE_A4,2, 173 | NOTE_D5,-8, NOTE_A5,-8, NOTE_A5,-8, NOTE_A5,-8, NOTE_G5,-8, NOTE_F5,-8, 174 | 175 | NOTE_E5,8, NOTE_C5,4, NOTE_A4,8, NOTE_G4,2, //26 176 | NOTE_E5,8, NOTE_C5,4, NOTE_G4,8, REST,4, NOTE_GS4,4, 177 | NOTE_A4,8, NOTE_F5,4, NOTE_F5,8, NOTE_A4,2, 178 | NOTE_B4,8, NOTE_F5,4, NOTE_F5,8, NOTE_F5,-8, NOTE_E5,-8, NOTE_D5,-8, 179 | NOTE_C5,8, NOTE_E4,4, NOTE_E4,8, NOTE_C4,2, 180 | NOTE_C5,8, NOTE_C5,4, NOTE_C5,8, REST,8, NOTE_C5,8, NOTE_D5,8, NOTE_E5,8, 181 | REST,1, 182 | 183 | NOTE_C5,8, NOTE_C5,4, NOTE_C5,8, REST,8, NOTE_C5,8, NOTE_D5,4, //33 184 | NOTE_E5,8, NOTE_C5,4, NOTE_A4,8, NOTE_G4,2, 185 | NOTE_E5,8, NOTE_E5,8, REST,8, NOTE_E5,8, REST,8, NOTE_C5,8, NOTE_E5,4, 186 | NOTE_G5,4, REST,4, NOTE_G4,4, REST,4, 187 | NOTE_E5,8, NOTE_C5,4, NOTE_G4,8, REST,4, NOTE_GS4,4, 188 | NOTE_A4,8, NOTE_F5,4, NOTE_F5,8, NOTE_A4,2, 189 | NOTE_D5,-8, NOTE_A5,-8, NOTE_A5,-8, NOTE_A5,-8, NOTE_G5,-8, NOTE_F5,-8, 190 | 191 | NOTE_E5,8, NOTE_C5,4, NOTE_A4,8, NOTE_G4,2, //40 192 | NOTE_E5,8, NOTE_C5,4, NOTE_G4,8, REST,4, NOTE_GS4,4, 193 | NOTE_A4,8, NOTE_F5,4, NOTE_F5,8, NOTE_A4,2, 194 | NOTE_B4,8, NOTE_F5,4, NOTE_F5,8, NOTE_F5,-8, NOTE_E5,-8, NOTE_D5,-8, 195 | NOTE_C5,8, NOTE_E4,4, NOTE_E4,8, NOTE_C4,2, 196 | 197 | //game over sound 198 | NOTE_C5,-4, NOTE_G4,-4, NOTE_E4,4, //45 199 | NOTE_A4,-8, NOTE_B4,-8, NOTE_A4,-8, NOTE_GS4,-8, NOTE_AS4,-8, NOTE_GS4,-8, 200 | NOTE_G4,8, NOTE_D4,8, NOTE_E4,-2, 201 | 202 | }; 203 | 204 | // sizeof gives the number of bytes, each int value is composed of two bytes (16 bits) 205 | // there are two values per note (pitch and duration), so for each note there are four bytes 206 | int notes = sizeof(melody) / sizeof(melody[0]) / 2; 207 | 208 | // this calculates the duration of a whole note in ms 209 | int wholenote = (60000 * 4) / tempo; 210 | 211 | int divider = 0, noteDuration = 0; 212 | 213 | void setup() { 214 | // iterate over the notes of the melody. 215 | // Remember, the array is twice the number of notes (notes + durations) 216 | for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) { 217 | 218 | // calculates the duration of each note 219 | divider = melody[thisNote + 1]; 220 | if (divider > 0) { 221 | // regular note, just proceed 222 | noteDuration = (wholenote) / divider; 223 | } else if (divider < 0) { 224 | // dotted notes are represented with negative durations!! 225 | noteDuration = (wholenote) / abs(divider); 226 | noteDuration *= 1.5; // increases the duration in half for dotted notes 227 | } 228 | 229 | // we only play the note for 90% of the duration, leaving 10% as a pause 230 | tone(buzzer, melody[thisNote], noteDuration * 0.9); 231 | 232 | // Wait for the specief duration before playing the next note. 233 | delay(noteDuration); 234 | 235 | // stop the waveform generation before the next note. 236 | noTone(buzzer); 237 | } 238 | } 239 | 240 | void loop() { 241 | // no need to repeat the melody. 242 | } 243 | --------------------------------------------------------------------------------