From c06648f755fe3fbb2ef9dbef074998cee5cd0807 Mon Sep 17 00:00:00 2001 From: Jordan Miller Date: Fri, 19 Aug 2016 10:11:53 -0500 Subject: [PATCH] adding arduino music project and other assorted musical scores from around the internet --- .../A_Theme___Tetris_with_Bass.ino | 132 ++++++++ .../A_Theme___Tetris_with_Bass/pitches.h | 94 ++++++ .../A_Theme___Tetris_with_Bass/version.md | 53 ++++ .../A_Theme___Tetris_with_Bass/version.txt | 46 +++ .../GameOfThronesTheme/GameOfThronesTheme.ino | 264 ++++++++++++++++ .../ImperialDeathMarch/ImperialDeathMarch.ino | 273 ++++++++++++++++ .../Nyan_Cat/Nyan_Cat.ino | 140 ++++++++ .../Arduino-Music-Project/Nyan_Cat/pitches.h | 94 ++++++ .../Arduino-Music-Project/Nyan_Cat/version.md | 53 ++++ .../Nyan_Cat/version.txt | 47 +++ examples/Arduino-Music-Project/license.txt | Bin 0 -> 2310 bytes .../mario/mario/mario.ino | 299 ++++++++++++++++++ examples/Arduino-Music-Project/readme.md | 10 + 13 files changed, 1505 insertions(+) create mode 100644 examples/Arduino-Music-Project/A_Theme___Tetris_with_Bass/A_Theme___Tetris_with_Bass.ino create mode 100755 examples/Arduino-Music-Project/A_Theme___Tetris_with_Bass/pitches.h create mode 100755 examples/Arduino-Music-Project/A_Theme___Tetris_with_Bass/version.md create mode 100755 examples/Arduino-Music-Project/A_Theme___Tetris_with_Bass/version.txt create mode 100644 examples/Arduino-Music-Project/GameOfThronesTheme/GameOfThronesTheme.ino create mode 100644 examples/Arduino-Music-Project/ImperialDeathMarch/ImperialDeathMarch.ino create mode 100644 examples/Arduino-Music-Project/Nyan_Cat/Nyan_Cat.ino create mode 100755 examples/Arduino-Music-Project/Nyan_Cat/pitches.h create mode 100755 examples/Arduino-Music-Project/Nyan_Cat/version.md create mode 100755 examples/Arduino-Music-Project/Nyan_Cat/version.txt create mode 100755 examples/Arduino-Music-Project/license.txt create mode 100644 examples/Arduino-Music-Project/mario/mario/mario.ino create mode 100755 examples/Arduino-Music-Project/readme.md diff --git a/examples/Arduino-Music-Project/A_Theme___Tetris_with_Bass/A_Theme___Tetris_with_Bass.ino b/examples/Arduino-Music-Project/A_Theme___Tetris_with_Bass/A_Theme___Tetris_with_Bass.ino new file mode 100644 index 0000000..7f2babe --- /dev/null +++ b/examples/Arduino-Music-Project/A_Theme___Tetris_with_Bass/A_Theme___Tetris_with_Bass.ino @@ -0,0 +1,132 @@ +/*A Theme - Tetris + with Bass + Uses Arduino tone library pitches.h [http://arduino.cc/en/Tutorial/tone ] + by electricmango + https://electricmango.github.io + + Thanks to Gori Fater for uploading the sheet music on Google. + http://www.gamemusicthemes.com/sheetmusic/gameboy/tetris/ + + Version 1.0.4 + ------------------------------------------------------------------------- + A Theme - Tetris with Bass is licensed under the + + Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) + + You are free to: + + Share — copy and redistribute the material in any medium or format + Adapt — remix, transform, and build upon the material + for any purpose, even commercially. + The licensor cannot revoke these freedoms as long as you follow the license terms. + + Under the following terms: + + Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use. + ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original. + + No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits. + + The full license is available at https://creativecommons.org/licenses/by-sa/4.0/legalcode + + Copyright (c) 2012 ~ 2015 electricmango + ------------------------------------------------------------------------- + A_Theme___Tetris_with_Bass.ino +*/ + +#include "pitches.h" + +//notes in the melody: +int melody[] = { + NOTE_E5, NOTE_E3, NOTE_B4, NOTE_C5, NOTE_D5, NOTE_E5, NOTE_D5, NOTE_C5, + NOTE_B4, NOTE_A4, NOTE_A3, NOTE_A4, NOTE_C5, NOTE_E5, NOTE_A3, NOTE_D5, + NOTE_C5, NOTE_B4, NOTE_E4, NOTE_G4, NOTE_C5, NOTE_D5, NOTE_E3, NOTE_E5, + NOTE_E3, NOTE_C5, NOTE_A3, NOTE_A4, NOTE_A3, NOTE_A4, NOTE_A3, NOTE_B2, + NOTE_C3, NOTE_D3, NOTE_D5, NOTE_F5, NOTE_A5, NOTE_C5, NOTE_C5, NOTE_G5, + NOTE_F5, NOTE_E5, NOTE_C3, 0, NOTE_C5, NOTE_E5, NOTE_A4, NOTE_G4, NOTE_D5, + NOTE_C5, NOTE_B4, NOTE_E4, NOTE_B4, NOTE_C5, NOTE_D5, NOTE_G4, NOTE_E5, + NOTE_G4, NOTE_C5, NOTE_E4, NOTE_A4, NOTE_E3, NOTE_A4, 0, + NOTE_E5, NOTE_E3, NOTE_B4, NOTE_C5, NOTE_D5, NOTE_E5, NOTE_D5, NOTE_C5, + NOTE_B4, NOTE_A4, NOTE_A3, NOTE_A4, NOTE_C5, NOTE_E5, NOTE_A3, NOTE_D5, + NOTE_C5, NOTE_B4, NOTE_E4, NOTE_G4, NOTE_C5, NOTE_D5, NOTE_E3, NOTE_E5, + NOTE_E3, NOTE_C5, NOTE_A3, NOTE_A4, NOTE_A3, NOTE_A4, NOTE_A3, NOTE_B2, + NOTE_C3, NOTE_D3, NOTE_D5, NOTE_F5, NOTE_A5, NOTE_C5, NOTE_C5, NOTE_G5, + NOTE_F5, NOTE_E5, NOTE_C3, 0, NOTE_C5, NOTE_E5, NOTE_A4, NOTE_G4, NOTE_D5, + NOTE_C5, NOTE_B4, NOTE_E4, NOTE_B4, NOTE_C5, NOTE_D5, NOTE_G4, NOTE_E5, + NOTE_G4, NOTE_C5, NOTE_E4, NOTE_A4, NOTE_E3, NOTE_A4, 0, + NOTE_E4, NOTE_E3, NOTE_A2, NOTE_E3, NOTE_C4, NOTE_E3, NOTE_A2, NOTE_E3, + NOTE_D4, NOTE_E3, NOTE_GS2, NOTE_E3, NOTE_B3, NOTE_E3, NOTE_GS2, NOTE_E3, + NOTE_C4, NOTE_E3, NOTE_A2, NOTE_E3, NOTE_A3, NOTE_E3, NOTE_A2, NOTE_E3, + NOTE_GS3, NOTE_E3, NOTE_GS2, NOTE_E3, NOTE_B3, NOTE_E3, NOTE_GS2, NOTE_E3, + NOTE_E4, NOTE_E3, NOTE_A2, NOTE_E3, NOTE_C4, NOTE_E3, NOTE_A2, NOTE_E3, + NOTE_D4, NOTE_E3, NOTE_GS2, NOTE_E3, NOTE_B3, NOTE_E3, NOTE_GS2, NOTE_E3, + NOTE_C4, NOTE_E3, NOTE_E4, NOTE_E3, NOTE_A4, NOTE_E3, NOTE_A2, NOTE_E3, + NOTE_GS4, NOTE_E3, NOTE_GS2, NOTE_E3, NOTE_GS2, NOTE_E3, NOTE_GS2, NOTE_E3, + NOTE_E5, NOTE_E3, NOTE_B4, NOTE_C5, NOTE_D5, NOTE_E5, NOTE_D5, NOTE_C5, + NOTE_B4, NOTE_A4, NOTE_A3, NOTE_A4, NOTE_C5, NOTE_E5, NOTE_A3, NOTE_D5, + NOTE_C5, NOTE_B4, NOTE_E4, NOTE_G4, NOTE_C5, NOTE_D5, NOTE_E3, NOTE_E5, + NOTE_E3, NOTE_C5, NOTE_A3, NOTE_A4, NOTE_A3, NOTE_A4, NOTE_A3, NOTE_B2, + NOTE_C3, NOTE_D3, NOTE_D5, NOTE_F5, NOTE_A5, NOTE_C5, NOTE_C5, NOTE_G5, + NOTE_F5, NOTE_E5, NOTE_C3, 0, NOTE_C5, NOTE_E5, NOTE_A4, NOTE_G4, NOTE_D5, + NOTE_C5, NOTE_B4, NOTE_E4, NOTE_B4, NOTE_C5, NOTE_D5, NOTE_G4, NOTE_E5, + NOTE_G4, NOTE_C5, NOTE_E4, NOTE_A4, NOTE_E3, NOTE_A4, 0, + NOTE_E5, NOTE_E3, NOTE_B4, NOTE_C5, NOTE_D5, NOTE_E5, NOTE_D5, NOTE_C5, + NOTE_B4, NOTE_A4, NOTE_A3, NOTE_A4, NOTE_C5, NOTE_E5, NOTE_A3, NOTE_D5, + NOTE_C5, NOTE_B4, NOTE_E4, NOTE_G4, NOTE_C5, NOTE_D5, NOTE_E3, NOTE_E5, + NOTE_E3, NOTE_C5, NOTE_A3, NOTE_A4, NOTE_A3, NOTE_A4, NOTE_A3, NOTE_B2, + NOTE_C3, NOTE_D3, NOTE_D5, NOTE_F5, NOTE_A5, NOTE_C5, NOTE_C5, NOTE_G5, + NOTE_F5, NOTE_E5, NOTE_C3, 0, NOTE_C5, NOTE_E5, NOTE_A4, NOTE_G4, NOTE_D5, + NOTE_C5, NOTE_B4, NOTE_E4, NOTE_B4, NOTE_C5, NOTE_D5, NOTE_G4, NOTE_E5, + NOTE_G4, NOTE_C5, NOTE_E4, NOTE_A4, NOTE_E3, NOTE_A4, 0, + NOTE_E4, NOTE_E3, NOTE_A2, NOTE_E3, NOTE_C4, NOTE_E3, NOTE_A2, NOTE_E3, + NOTE_D4, NOTE_E3, NOTE_GS2, NOTE_E3, NOTE_B3, NOTE_E3, NOTE_GS2, NOTE_E3, + NOTE_C4, NOTE_E3, NOTE_A2, NOTE_E3, NOTE_A3, NOTE_E3, NOTE_A2, NOTE_E3, + NOTE_GS3, NOTE_E3, NOTE_GS2, NOTE_E3, NOTE_B3, NOTE_E3, NOTE_GS2, NOTE_E3, + NOTE_E4, NOTE_E3, NOTE_A2, NOTE_E3, NOTE_C4, NOTE_E3, NOTE_A2, NOTE_E3, + NOTE_D4, NOTE_E3, NOTE_GS2, NOTE_E3, NOTE_B3, NOTE_E3, NOTE_GS2, NOTE_E3, + NOTE_C4, NOTE_E3, NOTE_E4, NOTE_E3, NOTE_A4, NOTE_E3, NOTE_A2, NOTE_E3, + NOTE_GS4, NOTE_E3, NOTE_GS2, NOTE_E3, NOTE_GS2, NOTE_E3, NOTE_GS2, NOTE_E3, +}; + +//note durations: 4 = quarter note, 8 = eighth note, etc +int noteDurations[] = { + 8,8,8,8,8,16,16,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,4,8,8,16,16,8,8,8,8,8,8,8,16,16,8,8,8,8,8,8,8,8,8,8,8,8,8,8,4,4, + 8,8,8,8,8,16,16,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,4,8,8,16,16,8,8,8,8,8,8,8,16,16,8,8,8,8,8,8,8,8,8,8,8,8,8,8,4,4, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,16,16,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,4,8,8,16,16,8,8,8,8,8,8,8,16,16,8,8,8,8,8,8,8,8,8,8,8,8,8,8,4,4, + 8,8,8,8,8,16,16,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,4,8,8,16,16,8,8,8,8,8,8,8,16,16,8,8,8,8,8,8,8,8,8,8,8,8,8,8,4,4, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, +}; + +void setup(){ + //iterate over the notes of the melody: + for (int thisNote = 0; thisNote < 1000; thisNote++){ + + /* + to calculate the note duration, take one second divided by the note type. + e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc. + */ + int noteDuration = 1000/noteDurations[thisNote]; + tone(5, melody[thisNote],noteDuration); + + /* + to distinguish the notes, set a minimum time between them. + the note's duration + 30% seems to work well: + */ + int pauseBetweenNotes = noteDuration * 1.30; + delay(pauseBetweenNotes); + + noTone(5); //stop the tone playing: + } + digitalWrite(5,LOW); +} + +void loop(){ /*press reset to replay. */ } + + diff --git a/examples/Arduino-Music-Project/A_Theme___Tetris_with_Bass/pitches.h b/examples/Arduino-Music-Project/A_Theme___Tetris_with_Bass/pitches.h new file mode 100755 index 0000000..7cbdec3 --- /dev/null +++ b/examples/Arduino-Music-Project/A_Theme___Tetris_with_Bass/pitches.h @@ -0,0 +1,94 @@ + /************************************************* + * Public Constants (available at http://arduino.cc/en/Tutorial/tone ) + *************************************************/ + +#define NOTE_B0 31 +#define NOTE_C1 33 +#define NOTE_CS1 35 +#define NOTE_D1 37 +#define NOTE_DS1 39 +#define NOTE_E1 41 +#define NOTE_F1 44 +#define NOTE_FS1 46 +#define NOTE_G1 49 +#define NOTE_GS1 52 +#define NOTE_A1 55 +#define NOTE_AS1 58 +#define NOTE_B1 62 +#define NOTE_C2 65 +#define NOTE_CS2 69 +#define NOTE_D2 73 +#define NOTE_DS2 78 +#define NOTE_E2 82 +#define NOTE_F2 87 +#define NOTE_FS2 93 +#define NOTE_G2 98 +#define NOTE_GS2 104 +#define NOTE_A2 110 +#define NOTE_AS2 117 +#define NOTE_B2 123 +#define NOTE_C3 131 +#define NOTE_CS3 139 +#define NOTE_D3 147 +#define NOTE_DS3 156 +#define NOTE_E3 165 +#define NOTE_F3 175 +#define NOTE_FS3 185 +#define NOTE_G3 196 +#define NOTE_GS3 208 +#define NOTE_A3 220 +#define NOTE_AS3 233 +#define NOTE_B3 247 +#define NOTE_C4 262 +#define NOTE_CS4 277 +#define NOTE_D4 294 +#define NOTE_DS4 311 +#define NOTE_E4 330 +#define NOTE_F4 349 +#define NOTE_FS4 370 +#define NOTE_G4 392 +#define NOTE_GS4 415 +#define NOTE_A4 440 +#define NOTE_AS4 466 +#define NOTE_B4 494 +#define NOTE_C5 523 +#define NOTE_CS5 554 +#define NOTE_D5 587 +#define NOTE_DS5 622 +#define NOTE_E5 659 +#define NOTE_F5 698 +#define NOTE_FS5 740 +#define NOTE_G5 784 +#define NOTE_GS5 831 +#define NOTE_A5 880 +#define NOTE_AS5 932 +#define NOTE_B5 988 +#define NOTE_C6 1047 +#define NOTE_CS6 1109 +#define NOTE_D6 1175 +#define NOTE_DS6 1245 +#define NOTE_E6 1319 +#define NOTE_F6 1397 +#define NOTE_FS6 1480 +#define NOTE_G6 1568 +#define NOTE_GS6 1661 +#define NOTE_A6 1760 +#define NOTE_AS6 1865 +#define NOTE_B6 1976 +#define NOTE_C7 2093 +#define NOTE_CS7 2217 +#define NOTE_D7 2349 +#define NOTE_DS7 2489 +#define NOTE_E7 2637 +#define NOTE_F7 2794 +#define NOTE_FS7 2960 +#define NOTE_G7 3136 +#define NOTE_GS7 3322 +#define NOTE_A7 3520 +#define NOTE_AS7 3729 +#define NOTE_B7 3951 +#define NOTE_C8 4186 +#define NOTE_CS8 4435 +#define NOTE_D8 4699 +#define NOTE_DS8 4978 + diff --git a/examples/Arduino-Music-Project/A_Theme___Tetris_with_Bass/version.md b/examples/Arduino-Music-Project/A_Theme___Tetris_with_Bass/version.md new file mode 100755 index 0000000..17d5e2d --- /dev/null +++ b/examples/Arduino-Music-Project/A_Theme___Tetris_with_Bass/version.md @@ -0,0 +1,53 @@ +#A Theme - Tetris with Bass +####by electricmango + + + +Uses **Arduino tone library pitches.h ** + +Thanks to Gori Fater for uploading the sheet music on Google + + + +version 1.0.4 + +--- +The **A Theme - Tetris with Bass** is licensed under the + +Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) + +You are free to: + +Share — copy and redistribute the material in any medium or format +Adapt — remix, transform, and build upon the material +for any purpose, even commercially. +The licensor cannot revoke these freedoms as long as you follow the license terms. + +Under the following terms: + +Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use. +ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original. + +No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits. + +The full license is available at + +Copyright (c) 2012 ~ 2015 electricmango + +--- +##version.txt + +######1.0.4 (1.27.15) + - some more minor changes + +######1.0.3 (1.24.15) +* minor refinements + +######1.0.2 (3.3.14) +* Updated licenses + +######1.0.1 (6.10.12) +* Copyright & Version Notes + +######1.0.0 (1.27.12) +* Finished melody + bass \ No newline at end of file diff --git a/examples/Arduino-Music-Project/A_Theme___Tetris_with_Bass/version.txt b/examples/Arduino-Music-Project/A_Theme___Tetris_with_Bass/version.txt new file mode 100755 index 0000000..a34ba29 --- /dev/null +++ b/examples/Arduino-Music-Project/A_Theme___Tetris_with_Bass/version.txt @@ -0,0 +1,46 @@ +A Theme - Tetris +with Bass +Uses Arduino tone library pitches.h [http://arduino.cc/en/Tutorial/tone ] + by electricmango +https://electricmango.github.io + +Version 1.0.4 +------------------------------------------------------------------------- +A Theme - Tetris with Bass is licensed under the + +Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) + +You are free to: + +Share — copy and redistribute the material in any medium or format +Adapt — remix, transform, and build upon the material +for any purpose, even commercially. +The licensor cannot revoke these freedoms as long as you follow the license terms. + +Under the following terms: + +Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use. +ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original. + +No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits. + +The full license is available at https://creativecommons.org/licenses/by-sa/4.0/legalcode + +Copyright (c) 2012 ~ 2015 electricmango +------------------------------------------------------------------------- +version.txt + +1.0.4 (1.27.15) + - some more minor changes + +1.0.3 (1.24.15) + - minor refinements + +1.0.2 (3.3.14) + - Updated licenses + +1.0.1 (6.10.12) + - Copyright & Version Notes + +1.0.0 (1.27.12) + - Finished melody + bass \ No newline at end of file diff --git a/examples/Arduino-Music-Project/GameOfThronesTheme/GameOfThronesTheme.ino b/examples/Arduino-Music-Project/GameOfThronesTheme/GameOfThronesTheme.ino new file mode 100644 index 0000000..1db47a7 --- /dev/null +++ b/examples/Arduino-Music-Project/GameOfThronesTheme/GameOfThronesTheme.ino @@ -0,0 +1,264 @@ +// From http://www.instructables.com/id/Game-Of-Thrones-Theme-on-Arduino/step2/SOFTWARE/ +// Adafruit Circuit Playground has pin 5 as the buzzer + + +#define NOTE_B0 31 +#define NOTE_C1 33 +#define NOTE_CS1 35 +#define NOTE_D1 37 +#define NOTE_DS1 39 +#define NOTE_E1 41 +#define NOTE_F1 44 +#define NOTE_FS1 46 +#define NOTE_G1 49 +#define NOTE_GS1 52 +#define NOTE_A1 55 +#define NOTE_AS1 58 +#define NOTE_B1 62 +#define NOTE_C2 65 +#define NOTE_CS2 69 +#define NOTE_D2 73 +#define NOTE_DS2 78 +#define NOTE_E2 82 +#define NOTE_F2 87 +#define NOTE_FS2 93 +#define NOTE_G2 98 +#define NOTE_GS2 104 +#define NOTE_A2 110 +#define NOTE_AS2 117 +#define NOTE_B2 123 +#define NOTE_C3 131 +#define NOTE_CS3 139 +#define NOTE_D3 147 +#define NOTE_DS3 156 +#define NOTE_E3 165 +#define NOTE_F3 175 +#define NOTE_FS3 185 +#define NOTE_G3 196 +#define NOTE_GS3 208 +#define NOTE_A3 220 +#define NOTE_AS3 233 +#define NOTE_B3 247 +#define NOTE_C4 262 +#define NOTE_CS4 277 +#define NOTE_D4 294 +#define NOTE_DS4 311 +#define NOTE_E4 330 +#define NOTE_F4 349 +#define NOTE_FS4 370 +#define NOTE_G4 392 +#define NOTE_GS4 415 +#define NOTE_A4 440 +#define NOTE_AS4 466 +#define NOTE_B4 494 +#define NOTE_C5 523 +#define NOTE_CS5 554 +#define NOTE_D5 587 +#define NOTE_DS5 622 +#define NOTE_E5 659 +#define NOTE_F5 698 +#define NOTE_FS5 740 +#define NOTE_G5 784 +#define NOTE_GS5 831 +#define NOTE_A5 880 +#define NOTE_AS5 932 +#define NOTE_B5 988 +#define NOTE_C6 1047 +#define NOTE_CS6 1109 +#define NOTE_D6 1175 +#define NOTE_DS6 1245 +#define NOTE_E6 1319 +#define NOTE_F6 1397 +#define NOTE_FS6 1480 +#define NOTE_G6 1568 +#define NOTE_GS6 1661 +#define NOTE_A6 1760 +#define NOTE_AS6 1865 +#define NOTE_B6 1976 +#define NOTE_C7 2093 +#define NOTE_CS7 2217 +#define NOTE_D7 2349 +#define NOTE_DS7 2489 +#define NOTE_E7 2637 +#define NOTE_F7 2794 +#define NOTE_FS7 2960 +#define NOTE_G7 3136 +#define NOTE_GS7 3322 +#define NOTE_A7 3520 +#define NOTE_AS7 3729 +#define NOTE_B7 3951 +#define NOTE_C8 4186 +#define NOTE_CS8 4435 +#define NOTE_D8 4699 +#define NOTE_DS8 4978 +int speakerPin=5; +void GameOfThrones(); +void setup() + { + pinMode(speakerPin,OUTPUT); + } +void loop() + { //play when entering or leaving you thrones, chair etc. + GameOfThrones(); + } + + +void GameOfThrones() + { + for(int i=0; i<4; i++) + { + tone(speakerPin, NOTE_G4); + delay(500); + noTone(speakerPin); + tone(speakerPin, NOTE_C4); + delay(500); + noTone(speakerPin); + tone(speakerPin, NOTE_DS4); + delay(250); + noTone(speakerPin); + tone(speakerPin, NOTE_F4); + delay(250); + noTone(speakerPin); + } + for(int i=0; i<4; i++) + { + tone(speakerPin, NOTE_G4); + delay(500); + noTone(speakerPin); + tone(speakerPin, NOTE_C4); + delay(500); + noTone(speakerPin); + tone(speakerPin, NOTE_E4); + delay(250); + noTone(speakerPin); + tone(speakerPin, NOTE_F4); + delay(250); + noTone(speakerPin); + } + tone(speakerPin, NOTE_G4); + delay(500); + noTone(speakerPin); + tone(speakerPin, NOTE_C4); + delay(500); + tone(speakerPin, NOTE_DS4); + delay(250); + noTone(speakerPin); + tone(speakerPin, NOTE_F4); + delay(250); + noTone(speakerPin); + tone(speakerPin, NOTE_D4); + delay(500); + noTone(speakerPin); + for(int i=0; i<3; i++) + { + tone(speakerPin, NOTE_G3); + delay(500); + noTone(speakerPin); + tone(speakerPin, NOTE_AS3); + delay(250); + noTone(speakerPin); + tone(speakerPin, NOTE_C4); + delay(250); + noTone(speakerPin); + tone(speakerPin, NOTE_D4); + delay(500); + noTone(speakerPin); + }// + tone(speakerPin, NOTE_G3); + delay(500); + noTone(speakerPin); + tone(speakerPin, NOTE_AS3); + delay(250); + noTone(speakerPin); + tone(speakerPin, NOTE_C4); + delay(250); + noTone(speakerPin); + tone(speakerPin, NOTE_D4); + delay(1000); + noTone(speakerPin); + + tone(speakerPin, NOTE_F4); + delay(1000); + noTone(speakerPin); + tone(speakerPin, NOTE_AS3); + delay(1000); + noTone(speakerPin); + tone(speakerPin, NOTE_DS4); + delay(250); + noTone(speakerPin); + tone(speakerPin, NOTE_D4); + delay(250); + noTone(speakerPin); + tone(speakerPin, NOTE_F4); + delay(1000); + noTone(speakerPin); + tone(speakerPin, NOTE_AS3); + delay(1000); + noTone(speakerPin); + tone(speakerPin, NOTE_DS4); + delay(250); + noTone(speakerPin); + tone(speakerPin, NOTE_D4); + delay(250); + noTone(speakerPin); + tone(speakerPin, NOTE_C4); + delay(500); + noTone(speakerPin); + for(int i=0; i<3; i++) + { + tone(speakerPin, NOTE_GS3); + delay(250); + noTone(speakerPin); + tone(speakerPin, NOTE_AS3); + delay(250); + noTone(speakerPin); + tone(speakerPin, NOTE_C4); + delay(500); + noTone(speakerPin); + tone(speakerPin, NOTE_F3); + delay(500); + noTone(speakerPin); + } + tone(speakerPin, NOTE_G4); + delay(1000); + noTone(speakerPin); + tone(speakerPin, NOTE_C4); + delay(1000); + noTone(speakerPin); + tone(speakerPin, NOTE_DS4); + delay(250); + noTone(speakerPin); + tone(speakerPin, NOTE_F4); + delay(250); + noTone(speakerPin); + tone(speakerPin, NOTE_G4); + delay(1000); + noTone(speakerPin); + tone(speakerPin, NOTE_C4); + delay(1000); + noTone(speakerPin); + tone(speakerPin, NOTE_DS4); + delay(250); + noTone(speakerPin); + tone(speakerPin, NOTE_F4); + delay(250); + noTone(speakerPin); + tone(speakerPin, NOTE_D4); + delay(500); + noTone(speakerPin); + for(int i=0; i<4; i++) + { + tone(speakerPin, NOTE_G3); + delay(500); + noTone(speakerPin); + tone(speakerPin, NOTE_AS3); + delay(250); + noTone(speakerPin); + tone(speakerPin, NOTE_C4); + delay(250); + noTone(speakerPin); + tone(speakerPin, NOTE_D4); + delay(500); + noTone(speakerPin); + } +} diff --git a/examples/Arduino-Music-Project/ImperialDeathMarch/ImperialDeathMarch.ino b/examples/Arduino-Music-Project/ImperialDeathMarch/ImperialDeathMarch.ino new file mode 100644 index 0000000..a61c4c5 --- /dev/null +++ b/examples/Arduino-Music-Project/ImperialDeathMarch/ImperialDeathMarch.ino @@ -0,0 +1,273 @@ +// From: http://www.instructables.com/id/How-to-easily-play-music-with-buzzer-on-arduino-Th/ +// Set the write pin to 5 for Adafruit Circuit Playground + +// NB: ALL NOTES DEFINED WITH STANDARD ENGLISH NAMES, EXCEPT FROM "A" +//THAT IS CALLED WITH THE ITALIAN NAME "LA" BECAUSE A0,A1...ARE THE ANALOG PINS ON ARDUINO. +// (Ab IS CALLED Ab AND NOT LAb) +#define C0 16.35 +#define Db0 17.32 +#define D0 18.35 +#define Eb0 19.45 +#define E0 20.60 +#define F0 21.83 +#define Gb0 23.12 +#define G0 24.50 +#define Ab0 25.96 +#define LA0 27.50 +#define Bb0 29.14 +#define B0 30.87 +#define C1 32.70 +#define Db1 34.65 +#define D1 36.71 +#define Eb1 38.89 +#define E1 41.20 +#define F1 43.65 +#define Gb1 46.25 +#define G1 49.00 +#define Ab1 51.91 +#define LA1 55.00 +#define Bb1 58.27 +#define B1 61.74 +#define C2 65.41 +#define Db2 69.30 +#define D2 73.42 +#define Eb2 77.78 +#define E2 82.41 +#define F2 87.31 +#define Gb2 92.50 +#define G2 98.00 +#define Ab2 103.83 +#define LA2 110.00 +#define Bb2 116.54 +#define B2 123.47 +#define C3 130.81 +#define Db3 138.59 +#define D3 146.83 +#define Eb3 155.56 +#define E3 164.81 +#define F3 174.61 +#define Gb3 185.00 +#define G3 196.00 +#define Ab3 207.65 +#define LA3 220.00 +#define Bb3 233.08 +#define B3 246.94 +#define C4 261.63 +#define Db4 277.18 +#define D4 293.66 +#define Eb4 311.13 +#define E4 329.63 +#define F4 349.23 +#define Gb4 369.99 +#define G4 392.00 +#define Ab4 415.30 +#define LA4 440.00 +#define Bb4 466.16 +#define B4 493.88 +#define C5 523.25 +#define Db5 554.37 +#define D5 587.33 +#define Eb5 622.25 +#define E5 659.26 +#define F5 698.46 +#define Gb5 739.99 +#define G5 783.99 +#define Ab5 830.61 +#define LA5 880.00 +#define Bb5 932.33 +#define B5 987.77 +#define C6 1046.50 +#define Db6 1108.73 +#define D6 1174.66 +#define Eb6 1244.51 +#define E6 1318.51 +#define F6 1396.91 +#define Gb6 1479.98 +#define G6 1567.98 +#define Ab6 1661.22 +#define LA6 1760.00 +#define Bb6 1864.66 +#define B6 1975.53 +#define C7 2093.00 +#define Db7 2217.46 +#define D7 2349.32 +#define Eb7 2489.02 +#define E7 2637.02 +#define F7 2793.83 +#define Gb7 2959.96 +#define G7 3135.96 +#define Ab7 3322.44 +#define LA7 3520.01 +#define Bb7 3729.31 +#define B7 3951.07 +#define C8 4186.01 +#define Db8 4434.92 +#define D8 4698.64 +#define Eb8 4978.03 +// DURATION OF THE NOTES +#define BPM 120 // you can change this value changing all the others +#define H 2*Q //half 2/4 +#define Q 60000/BPM //quarter 1/4 +#define E Q/2 //eighth 1/8 +#define S Q/4 // sixteenth 1/16 +#define W 4*Q // whole 4/4 + +void setup() { +pinMode(5, OUTPUT); + +} + +// the loop routine runs over and over again forever: +void loop() { + //tone(pin, note, duration) + tone(5,LA3,Q); + delay(1+Q); //delay duration should always be 1 ms more than the note in order to separate them. + tone(5,LA3,Q); + delay(1+Q); + tone(5,LA3,Q); + delay(1+Q); + tone(5,F3,E+S); + delay(1+E+S); + tone(5,C4,S); + delay(1+S); + + tone(5,LA3,Q); + delay(1+Q); + tone(5,F3,E+S); + delay(1+E+S); + tone(5,C4,S); + delay(1+S); + tone(5,LA3,H); + delay(1+H); + + tone(5,E4,Q); + delay(1+Q); + tone(5,E4,Q); + delay(1+Q); + tone(5,E4,Q); + delay(1+Q); + tone(5,F4,E+S); + delay(1+E+S); + tone(5,C4,S); + delay(1+S); + + tone(5,Ab3,Q); + delay(1+Q); + tone(5,F3,E+S); + delay(1+E+S); + tone(5,C4,S); + delay(1+S); + tone(5,LA3,H); + delay(1+H); + + tone(5,LA4,Q); + delay(1+Q); + tone(5,LA3,E+S); + delay(1+E+S); + tone(5,LA3,S); + delay(1+S); + tone(5,LA4,Q); + delay(1+Q); + tone(5,Ab4,E+S); + delay(1+E+S); + tone(5,G4,S); + delay(1+S); + + tone(5,Gb4,S); + delay(1+S); + tone(5,E4,S); + delay(1+S); + tone(5,F4,E); + delay(1+E); + delay(1+E);//PAUSE + tone(5,Bb3,E); + delay(1+E); + tone(5,Eb4,Q); + delay(1+Q); + tone(5,D4,E+S); + delay(1+E+S); + tone(5,Db4,S); + delay(1+S); + + tone(5,C4,S); + delay(1+S); + tone(5,B3,S); + delay(1+S); + tone(5,C4,E); + delay(1+E); + delay(1+E);//PAUSE QUASI FINE RIGA + tone(5,F3,E); + delay(1+E); + tone(5,Ab3,Q); + delay(1+Q); + tone(5,F3,E+S); + delay(1+E+S); + tone(5,LA3,S); + delay(1+S); + + tone(5,C4,Q); + delay(1+Q); + tone(5,LA3,E+S); + delay(1+E+S); + tone(5,C4,S); + delay(1+S); + tone(5,E4,H); + delay(1+H); + + tone(5,LA4,Q); + delay(1+Q); + tone(5,LA3,E+S); + delay(1+E+S); + tone(5,LA3,S); + delay(1+S); + tone(5,LA4,Q); + delay(1+Q); + tone(5,Ab4,E+S); + delay(1+E+S); + tone(5,G4,S); + delay(1+S); + + tone(5,Gb4,S); + delay(1+S); + tone(5,E4,S); + delay(1+S); + tone(5,F4,E); + delay(1+E); + delay(1+E);//PAUSE + tone(5,Bb3,E); + delay(1+E); + tone(5,Eb4,Q); + delay(1+Q); + tone(5,D4,E+S); + delay(1+E+S); + tone(5,Db4,S); + delay(1+S); + + tone(5,C4,S); + delay(1+S); + tone(5,B3,S); + delay(1+S); + tone(5,C4,E); + delay(1+E); + delay(1+E);//PAUSE QUASI FINE RIGA + tone(5,F3,E); + delay(1+E); + tone(5,Ab3,Q); + delay(1+Q); + tone(5,F3,E+S); + delay(1+E+S); + tone(5,C4,S); + delay(1+S); + + tone(5,LA3,Q); + delay(1+Q); + tone(5,F3,E+S); + delay(1+E+S); + tone(5,C4,S); + delay(1+S); + tone(5,LA3,H); + delay(1+H); + + delay(2*H); + +} diff --git a/examples/Arduino-Music-Project/Nyan_Cat/Nyan_Cat.ino b/examples/Arduino-Music-Project/Nyan_Cat/Nyan_Cat.ino new file mode 100644 index 0000000..5726150 --- /dev/null +++ b/examples/Arduino-Music-Project/Nyan_Cat/Nyan_Cat.ino @@ -0,0 +1,140 @@ +/*Nyan Cat + with Bass + Uses Arduino tone library pitches.h [http://arduino.cc/en/Tutorial/tone ] + by electricmango + https://electricmango.github.io + + Thanks to Sean for posting the sheet music on + http://junket.tumblr.com/post/4776023022/heres-the-nyan-cat-sheet-music + + Version 1.0.3 + ------------------------------------------------------------------------- + Nyan Cat with Bass is licensed under the + + Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) + + You are free to: + + Share — copy and redistribute the material in any medium or format + Adapt — remix, transform, and build upon the material + for any purpose, even commercially. + The licensor cannot revoke these freedoms as long as you follow the license terms. + + Under the following terms: + + Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use. + ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original. + + No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits. + + The full license is available at https://creativecommons.org/licenses/by-sa/4.0/legalcode + + Copyright (c) 2012 ~ 2015 electricmango + ------------------------------------------------------------------------- + Nyan_Cat.ino +*/ + +#include "pitches.h" + +//notes in the melody: +int melody[] = { + NOTE_DS5, NOTE_E5, NOTE_FS5, 0, NOTE_B5, NOTE_E5, NOTE_DS5, NOTE_E5, NOTE_FS5, NOTE_B5, NOTE_DS6, NOTE_E6, NOTE_DS6, NOTE_AS5, NOTE_B5, 0, + NOTE_FS5, 0, NOTE_DS5, NOTE_E5, NOTE_FS5, 0, NOTE_B5, NOTE_CS6, NOTE_AS5, NOTE_B5, NOTE_CS6, NOTE_E6, NOTE_DS6, NOTE_E6, NOTE_CS6, + NOTE_FS4, NOTE_GS4, NOTE_D4, NOTE_DS4, NOTE_FS2, NOTE_CS4, NOTE_D4, NOTE_CS4, NOTE_B3, NOTE_B3, NOTE_CS4, + NOTE_D4, NOTE_D4, NOTE_CS4, NOTE_B3, NOTE_CS4, NOTE_DS4, NOTE_FS4, NOTE_GS4, NOTE_DS4, NOTE_FS4, NOTE_CS4, NOTE_DS4, NOTE_B3, NOTE_CS4, NOTE_B3, + NOTE_DS4, NOTE_FS4, NOTE_GS4, NOTE_DS4, NOTE_FS4, NOTE_CS4, NOTE_DS4, NOTE_B3, NOTE_D4, NOTE_DS4, NOTE_D4, NOTE_CS4, NOTE_B3, NOTE_CS4, + NOTE_D4, NOTE_B3, NOTE_CS4, NOTE_DS4, NOTE_FS4, NOTE_CS4, NOTE_D4, NOTE_CS4, NOTE_B3, NOTE_CS4, NOTE_B3, NOTE_CS4, + NOTE_FS4, NOTE_GS4, NOTE_D4, NOTE_DS4, NOTE_FS2, NOTE_CS4, NOTE_D4, NOTE_CS4, NOTE_B3, NOTE_B3, NOTE_CS4, + NOTE_D4, NOTE_D4, NOTE_CS4, NOTE_B3, NOTE_CS4, NOTE_DS4, NOTE_FS4, NOTE_GS4, NOTE_DS4, NOTE_FS4, NOTE_CS4, NOTE_DS4, NOTE_B3, NOTE_CS4, NOTE_B3, + NOTE_DS4, NOTE_FS4, NOTE_GS4, NOTE_DS4, NOTE_FS4, NOTE_CS4, NOTE_DS4, NOTE_B3, NOTE_D4, NOTE_DS4, NOTE_D4, NOTE_CS4, NOTE_B3, NOTE_CS4, + NOTE_D4, NOTE_B3, NOTE_CS4, NOTE_DS4, NOTE_FS4, NOTE_CS4, NOTE_D4, NOTE_CS4, NOTE_B3, NOTE_CS4, NOTE_B3, NOTE_B3, + NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_CS4, NOTE_DS4, NOTE_B3, NOTE_E4, NOTE_DS4, NOTE_E4, NOTE_FS4, + NOTE_B3, NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_FS3, NOTE_E4, NOTE_DS4, NOTE_CS4, NOTE_B3, NOTE_E3, NOTE_DS3, NOTE_E3, NOTE_FS3, + NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_B3, NOTE_CS4, NOTE_DS4, NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_FS3, + NOTE_B3, NOTE_B3, NOTE_AS3, NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_E4, NOTE_DS4, NOTE_E4, NOTE_FS4, NOTE_B3, NOTE_AS3, + NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_CS4, NOTE_DS4, NOTE_B3, NOTE_E4, NOTE_DS4, NOTE_E4, NOTE_FS4, + NOTE_B3, NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_FS3, NOTE_E4, NOTE_DS4, NOTE_CS4, NOTE_B3, NOTE_E3, NOTE_DS3, NOTE_E3, NOTE_FS3, + NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_B3, NOTE_CS4, NOTE_DS4, NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_FS3, + NOTE_B3, NOTE_B3, NOTE_AS3, NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_E4, NOTE_DS4, NOTE_E4, NOTE_FS4, NOTE_B3, NOTE_CS4, + NOTE_FS4, NOTE_GS4, NOTE_D4, NOTE_DS4, NOTE_FS2, NOTE_CS4, NOTE_D4, NOTE_CS4, NOTE_B3, NOTE_B3, NOTE_CS4, + NOTE_D4, NOTE_D4, NOTE_CS4, NOTE_B3, NOTE_CS4, NOTE_DS4, NOTE_FS4, NOTE_GS4, NOTE_DS4, NOTE_FS4, NOTE_CS4, NOTE_DS4, NOTE_B3, NOTE_CS4, NOTE_B3, + NOTE_DS4, NOTE_FS4, NOTE_GS4, NOTE_DS4, NOTE_FS4, NOTE_CS4, NOTE_DS4, NOTE_B3, NOTE_D4, NOTE_DS4, NOTE_D4, NOTE_CS4, NOTE_B3, NOTE_CS4, + NOTE_D4, NOTE_B3, NOTE_CS4, NOTE_DS4, NOTE_FS4, NOTE_CS4, NOTE_D4, NOTE_CS4, NOTE_B3, NOTE_CS4, NOTE_B3, NOTE_CS4, + NOTE_FS4, NOTE_GS4, NOTE_D4, NOTE_DS4, NOTE_FS2, NOTE_CS4, NOTE_D4, NOTE_CS4, NOTE_B3, NOTE_B3, NOTE_CS4, + NOTE_D4, NOTE_D4, NOTE_CS4, NOTE_B3, NOTE_CS4, NOTE_DS4, NOTE_FS4, NOTE_GS4, NOTE_DS4, NOTE_FS4, NOTE_CS4, NOTE_DS4, NOTE_B3, NOTE_CS4, NOTE_B3, + NOTE_DS4, NOTE_FS4, NOTE_GS4, NOTE_DS4, NOTE_FS4, NOTE_CS4, NOTE_DS4, NOTE_B3, NOTE_D4, NOTE_DS4, NOTE_D4, NOTE_CS4, NOTE_B3, NOTE_CS4, + NOTE_D4, NOTE_B3, NOTE_CS4, NOTE_DS4, NOTE_FS4, NOTE_CS4, NOTE_D4, NOTE_CS4, NOTE_B3, NOTE_CS4, NOTE_B3, NOTE_B3, + NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_CS4, NOTE_DS4, NOTE_B3, NOTE_E4, NOTE_DS4, NOTE_E4, NOTE_FS4, + NOTE_B3, NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_FS3, NOTE_E4, NOTE_DS4, NOTE_CS4, NOTE_B3, NOTE_E3, NOTE_DS3, NOTE_E3, NOTE_FS3, + NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_B3, NOTE_CS4, NOTE_DS4, NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_FS3, + NOTE_B3, NOTE_B3, NOTE_AS3, NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_E4, NOTE_DS4, NOTE_E4, NOTE_FS4, NOTE_B3, NOTE_AS3, + NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_CS4, NOTE_DS4, NOTE_B3, NOTE_E4, NOTE_DS4, NOTE_E4, NOTE_FS4, + NOTE_B3, NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_FS3, NOTE_E4, NOTE_DS4, NOTE_CS4, NOTE_B3, NOTE_E3, NOTE_DS3, NOTE_E3, NOTE_FS3, + NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_B3, NOTE_CS4, NOTE_DS4, NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_FS3, + NOTE_B3, NOTE_B3, NOTE_AS3, NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_E4, NOTE_DS4, NOTE_E4, NOTE_FS4, NOTE_B3, NOTE_CS4, +}; + +// note durations: 4 = quarter note, 8 = eighth note, etc +int noteDurations[] = { + 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, + 16,16,16,16,16,16,8,16,16,16,16,16,16,16,16, + 8,8,16,16,16,16,16,16,8,8,8, + 8,16,16,16,16,16,16,16,16,16,16,16,16,16,16, + 8,8,16,16,16,16,16,16,16,16,16,16,16,16, + 8,16,16,16,16,16,16,16,16,8,8,8, + 8,8,16,16,16,16,16,16,8,8,8, + 8,16,16,16,16,16,16,16,16,16,16,16,16,16,16, + 8,8,16,16,16,16,16,16,16,16,16,16,16,16, + 8,16,16,16,16,16,16,16,16,8,8,8, + 8,16,16,8,16,16,16,16,16,16,16,16,16,16, + 8,8,16,16,16,16,16,16,16,16,16,16,16,16, + 8,16,16,8,16,16,16,16,16,16,16,16,16,16, + 8,16,16,16,16,16,16,16,16,16,16,8,8, + 8,16,16,8,16,16,16,16,16,16,16,16,16,16, + 8,8,16,16,16,16,16,16,16,16,16,16,16,16, + 8,16,16,8,16,16,16,16,16,16,16,16,16,16, + 8,16,16,16,16,16,16,16,16,16,16,8,8, + 8,8,16,16,16,16,16,16,8,8,8, + 8,16,16,16,16,16,16,16,16,16,16,16,16,16,16, + 8,8,16,16,16,16,16,16,16,16,16,16,16,16, + 8,16,16,16,16,16,16,16,16,8,8,8, + 8,8,16,16,16,16,16,16,8,8,8, + 8,16,16,16,16,16,16,16,16,16,16,16,16,16,16, + 8,8,16,16,16,16,16,16,16,16,16,16,16,16, + 8,16,16,16,16,16,16,16,16,8,8,8, + 8,16,16,8,16,16,16,16,16,16,16,16,16,16, + 8,8,16,16,16,16,16,16,16,16,16,16,16,16, + 8,16,16,8,16,16,16,16,16,16,16,16,16,16, + 8,16,16,16,16,16,16,16,16,16,16,8,8, + 8,16,16,8,16,16,16,16,16,16,16,16,16,16, + 8,8,16,16,16,16,16,16,16,16,16,16,16,16, + 8,16,16,8,16,16,16,16,16,16,16,16,16,16, + 8,16,16,16,16,16,16,16,16,16,16,8,8, +}; + +void setup(){ + //iterate over the notes of the melody: + for (int thisNote = 0; thisNote < 1000; thisNote++) { + + /* + to calculate the note duration, take one second divided by the note type. + e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc. + */ + int noteDuration = 1000/noteDurations[thisNote]; + tone(5, melody[thisNote],noteDuration); + + /* + to distinguish the notes, set a minimum time between them. + the note's duration + 30% seems to work well: + */ + int pauseBetweenNotes = noteDuration * 1.30; + delay(pauseBetweenNotes); + + noTone(5); //stop the tone playing: + } + digitalWrite(5,LOW); +} + +void loop(){ /*press reset to replay. */ } + + diff --git a/examples/Arduino-Music-Project/Nyan_Cat/pitches.h b/examples/Arduino-Music-Project/Nyan_Cat/pitches.h new file mode 100755 index 0000000..18741b0 --- /dev/null +++ b/examples/Arduino-Music-Project/Nyan_Cat/pitches.h @@ -0,0 +1,94 @@ +/************************************************* + * Public Constants (available at http://arduino.cc/en/Tutorial/tone ) + *************************************************/ + +#define NOTE_B0 31 +#define NOTE_C1 33 +#define NOTE_CS1 35 +#define NOTE_D1 37 +#define NOTE_DS1 39 +#define NOTE_E1 41 +#define NOTE_F1 44 +#define NOTE_FS1 46 +#define NOTE_G1 49 +#define NOTE_GS1 52 +#define NOTE_A1 55 +#define NOTE_AS1 58 +#define NOTE_B1 62 +#define NOTE_C2 65 +#define NOTE_CS2 69 +#define NOTE_D2 73 +#define NOTE_DS2 78 +#define NOTE_E2 82 +#define NOTE_F2 87 +#define NOTE_FS2 93 +#define NOTE_G2 98 +#define NOTE_GS2 104 +#define NOTE_A2 110 +#define NOTE_AS2 117 +#define NOTE_B2 123 +#define NOTE_C3 131 +#define NOTE_CS3 139 +#define NOTE_D3 147 +#define NOTE_DS3 156 +#define NOTE_E3 165 +#define NOTE_F3 175 +#define NOTE_FS3 185 +#define NOTE_G3 196 +#define NOTE_GS3 208 +#define NOTE_A3 220 +#define NOTE_AS3 233 +#define NOTE_B3 247 +#define NOTE_C4 262 +#define NOTE_CS4 277 +#define NOTE_D4 294 +#define NOTE_DS4 311 +#define NOTE_E4 330 +#define NOTE_F4 349 +#define NOTE_FS4 370 +#define NOTE_G4 392 +#define NOTE_GS4 415 +#define NOTE_A4 440 +#define NOTE_AS4 466 +#define NOTE_B4 494 +#define NOTE_C5 523 +#define NOTE_CS5 554 +#define NOTE_D5 587 +#define NOTE_DS5 622 +#define NOTE_E5 659 +#define NOTE_F5 698 +#define NOTE_FS5 740 +#define NOTE_G5 784 +#define NOTE_GS5 831 +#define NOTE_A5 880 +#define NOTE_AS5 932 +#define NOTE_B5 988 +#define NOTE_C6 1047 +#define NOTE_CS6 1109 +#define NOTE_D6 1175 +#define NOTE_DS6 1245 +#define NOTE_E6 1319 +#define NOTE_F6 1397 +#define NOTE_FS6 1480 +#define NOTE_G6 1568 +#define NOTE_GS6 1661 +#define NOTE_A6 1760 +#define NOTE_AS6 1865 +#define NOTE_B6 1976 +#define NOTE_C7 2093 +#define NOTE_CS7 2217 +#define NOTE_D7 2349 +#define NOTE_DS7 2489 +#define NOTE_E7 2637 +#define NOTE_F7 2794 +#define NOTE_FS7 2960 +#define NOTE_G7 3136 +#define NOTE_GS7 3322 +#define NOTE_A7 3520 +#define NOTE_AS7 3729 +#define NOTE_B7 3951 +#define NOTE_C8 4186 +#define NOTE_CS8 4435 +#define NOTE_D8 4699 +#define NOTE_DS8 4978 + diff --git a/examples/Arduino-Music-Project/Nyan_Cat/version.md b/examples/Arduino-Music-Project/Nyan_Cat/version.md new file mode 100755 index 0000000..bc9f7ba --- /dev/null +++ b/examples/Arduino-Music-Project/Nyan_Cat/version.md @@ -0,0 +1,53 @@ +#Nyan Cat with Bass +####by electricmango + + + +Uses **Arduino tone library pitches.h ** + +Arduino code repo for the music I make for the Arduino. + +Thanks to Sean for posting the sheet music on + + + +Version 1.0.3 + +--- +The **Nyan Cat with Bass** is licensed under the + +Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) + +You are free to: + +Share — copy and redistribute the material in any medium or format +Adapt — remix, transform, and build upon the material +for any purpose, even commercially. +The licensor cannot revoke these freedoms as long as you follow the license terms. + +Under the following terms: + +Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use. +ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original. + +No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits. + +The full license is available at + +Copyright (c) 2012 ~ 2015 electricmango + +--- + +##version.txt + +######1.0.3 (1.27.15) +* some more minor changes + +######1.0.2 (1.24.15) +* Minor refinements + +######1.0.1 (3.5.14) +* Updated licenses + +######1.0.0 (8.16.12) +* Released \ No newline at end of file diff --git a/examples/Arduino-Music-Project/Nyan_Cat/version.txt b/examples/Arduino-Music-Project/Nyan_Cat/version.txt new file mode 100755 index 0000000..b63aeb8 --- /dev/null +++ b/examples/Arduino-Music-Project/Nyan_Cat/version.txt @@ -0,0 +1,47 @@ +Nyan Cat +with Bass +Uses Arduino tone library pitches.h [http://arduino.cc/en/Tutorial/tone ] + by electricmango +https://electricmango.github.io + minhyukjang@gmail.com + +Thanks to Sean for posting the sheet music on +http://junket.tumblr.com/post/4776023022/heres-the-nyan-cat-sheet-music + +Version 1.0.3 +------------------------------------------------------------------------- +Nyan Cat with Bass is licensed under the + +Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) + +You are free to: + +Share — copy and redistribute the material in any medium or format +Adapt — remix, transform, and build upon the material +for any purpose, even commercially. +The licensor cannot revoke these freedoms as long as you follow the license terms. + +Under the following terms: + +Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use. +ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original. + +No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits. + +The full license is available at https://creativecommons.org/licenses/by-sa/4.0/legalcode + +Copyright (c) 2012 ~ 2015 electricmango +------------------------------------------------------------------------- +version.txt + +1.0.3 (1.27.15) + - some more minor changes + +1.0.2 (1.24.15) + - Minor refinements + +1.0.1 (3.5.14) + - Updated licenses + +1.0.0 (8.16.12) + - Released \ No newline at end of file diff --git a/examples/Arduino-Music-Project/license.txt b/examples/Arduino-Music-Project/license.txt new file mode 100755 index 0000000000000000000000000000000000000000..b1fdd49489208c2c47e0243a8e26c864b40bcdd8 GIT binary patch literal 2310 zcmaKtO>bgH5Jh{)xvB=HGw%WnR{0QhqK?8J36gSXR6}@f>4)W;J0wD8H5Sa>J)v&UpKbZN%>1 zJdJrv@!J~A9wCHF*( zi0cI7?58~TqZ&9q2I`#rb|t4_&C~g+JVaLe7|a*=);jD*JC$~5S3_mpc7Fx4tocjK zp7^z%zJEiVS*G+e*LI|KYXOJ5H~}l_;l92r5Y2EGO0uu3SI_pW=%4-gKo-x0C+I1v zl^h;7_0CzT?DuQe;?()cxk>#E^WIL8-AldSVLV6Q|Mf&I9kjo|&Y4rClUy;J7g^6k zdupsFwE9%mQ@qqRk51?Gs?vG1PkD}3+%BH%;by)@RB>MZB5T{1wtEfH-YIzl)oP}q zJdbT9ocDTGccWD0j6RX$E;4OTSnAax{@dNj-Z=~QK2N;oO2h>Wms|Sk$**p={Xsc3###@9CM>;>BfzE&B~iL@7Oc!2Y7hbx_=P;_!2kbC4RSYGbY9jetp(o z@fEv?wX0w8?{jB6Pv_Eol*C#4(WaGS@ zjq<-^5WlH#mzBtwPi8$*K$iJN8I^SA5i_st#*wZtZVg>({_z zK<2N3|A}3r^|_)hDpkP=Z~lvQ!8qaRs#VpGzFF~OJbKZqGv0fA98uN>~ukKm2)C{6+1!hIw$th8s~&;XLb6luwM4TRhNE_JGFt=~E$iIU11@UzotZR^rR)$LsJvUb_yjO-A%d-{&be+Id7zyJUM literal 0 HcmV?d00001 diff --git a/examples/Arduino-Music-Project/mario/mario/mario.ino b/examples/Arduino-Music-Project/mario/mario/mario.ino new file mode 100644 index 0000000..a248fc7 --- /dev/null +++ b/examples/Arduino-Music-Project/mario/mario/mario.ino @@ -0,0 +1,299 @@ +/* + Arduino Mario Bros Tunes + With Piezo Buzzer and PWM + + Connect the positive side of the Buzzer to pin 3, + then the negative side to a 1k ohm resistor. Connect + the other side of the 1 k ohm resistor to + ground(GND) pin on the Arduino. + + by: Dipto Pratyaksa + last updated: 31/3/13 +*/ + +/* + Update 2016-08-19 for Circuit Playground + by jmil + For Adafruit Circuit Playground, the magnetic buzzer is on pin 5 + So, all you need to do is upload this sketch and it will work + +*/ + + +/************************************************* + * Public Constants + *************************************************/ + +#define NOTE_B0 31 +#define NOTE_C1 33 +#define NOTE_CS1 35 +#define NOTE_D1 37 +#define NOTE_DS1 39 +#define NOTE_E1 41 +#define NOTE_F1 44 +#define NOTE_FS1 46 +#define NOTE_G1 49 +#define NOTE_GS1 52 +#define NOTE_A1 55 +#define NOTE_AS1 58 +#define NOTE_B1 62 +#define NOTE_C2 65 +#define NOTE_CS2 69 +#define NOTE_D2 73 +#define NOTE_DS2 78 +#define NOTE_E2 82 +#define NOTE_F2 87 +#define NOTE_FS2 93 +#define NOTE_G2 98 +#define NOTE_GS2 104 +#define NOTE_A2 110 +#define NOTE_AS2 117 +#define NOTE_B2 123 +#define NOTE_C3 131 +#define NOTE_CS3 139 +#define NOTE_D3 147 +#define NOTE_DS3 156 +#define NOTE_E3 165 +#define NOTE_F3 175 +#define NOTE_FS3 185 +#define NOTE_G3 196 +#define NOTE_GS3 208 +#define NOTE_A3 220 +#define NOTE_AS3 233 +#define NOTE_B3 247 +#define NOTE_C4 262 +#define NOTE_CS4 277 +#define NOTE_D4 294 +#define NOTE_DS4 311 +#define NOTE_E4 330 +#define NOTE_F4 349 +#define NOTE_FS4 370 +#define NOTE_G4 392 +#define NOTE_GS4 415 +#define NOTE_A4 440 +#define NOTE_AS4 466 +#define NOTE_B4 494 +#define NOTE_C5 523 +#define NOTE_CS5 554 +#define NOTE_D5 587 +#define NOTE_DS5 622 +#define NOTE_E5 659 +#define NOTE_F5 698 +#define NOTE_FS5 740 +#define NOTE_G5 784 +#define NOTE_GS5 831 +#define NOTE_A5 880 +#define NOTE_AS5 932 +#define NOTE_B5 988 +#define NOTE_C6 1047 +#define NOTE_CS6 1109 +#define NOTE_D6 1175 +#define NOTE_DS6 1245 +#define NOTE_E6 1319 +#define NOTE_F6 1397 +#define NOTE_FS6 1480 +#define NOTE_G6 1568 +#define NOTE_GS6 1661 +#define NOTE_A6 1760 +#define NOTE_AS6 1865 +#define NOTE_B6 1976 +#define NOTE_C7 2093 +#define NOTE_CS7 2217 +#define NOTE_D7 2349 +#define NOTE_DS7 2489 +#define NOTE_E7 2637 +#define NOTE_F7 2794 +#define NOTE_FS7 2960 +#define NOTE_G7 3136 +#define NOTE_GS7 3322 +#define NOTE_A7 3520 +#define NOTE_AS7 3729 +#define NOTE_B7 3951 +#define NOTE_C8 4186 +#define NOTE_CS8 4435 +#define NOTE_D8 4699 +#define NOTE_DS8 4978 + +#define melodyPin 5 +//Mario main theme melody +int melody[] = { + NOTE_E7, NOTE_E7, 0, NOTE_E7, + 0, NOTE_C7, NOTE_E7, 0, + NOTE_G7, 0, 0, 0, + NOTE_G6, 0, 0, 0, + + NOTE_C7, 0, 0, NOTE_G6, + 0, 0, NOTE_E6, 0, + 0, NOTE_A6, 0, NOTE_B6, + 0, NOTE_AS6, NOTE_A6, 0, + + NOTE_G6, NOTE_E7, NOTE_G7, + NOTE_A7, 0, NOTE_F7, NOTE_G7, + 0, NOTE_E7, 0, NOTE_C7, + NOTE_D7, NOTE_B6, 0, 0, + + NOTE_C7, 0, 0, NOTE_G6, + 0, 0, NOTE_E6, 0, + 0, NOTE_A6, 0, NOTE_B6, + 0, NOTE_AS6, NOTE_A6, 0, + + NOTE_G6, NOTE_E7, NOTE_G7, + NOTE_A7, 0, NOTE_F7, NOTE_G7, + 0, NOTE_E7, 0, NOTE_C7, + NOTE_D7, NOTE_B6, 0, 0 +}; + +//Mario main them tempo +int tempo[] = { + 12, 12, 12, 12, + 12, 12, 12, 12, + 12, 12, 12, 12, + 12, 12, 12, 12, + + 12, 12, 12, 12, + 12, 12, 12, 12, + 12, 12, 12, 12, + 12, 12, 12, 12, + + 9, 9, 9, + 12, 12, 12, 12, + 12, 12, 12, 12, + 12, 12, 12, 12, + + 12, 12, 12, 12, + 12, 12, 12, 12, + 12, 12, 12, 12, + 12, 12, 12, 12, + + 9, 9, 9, + 12, 12, 12, 12, + 12, 12, 12, 12, + 12, 12, 12, 12, +}; +//Underworld melody +int underworld_melody[] = { + NOTE_C4, NOTE_C5, NOTE_A3, NOTE_A4, + NOTE_AS3, NOTE_AS4, 0, + 0, + NOTE_C4, NOTE_C5, NOTE_A3, NOTE_A4, + NOTE_AS3, NOTE_AS4, 0, + 0, + NOTE_F3, NOTE_F4, NOTE_D3, NOTE_D4, + NOTE_DS3, NOTE_DS4, 0, + 0, + NOTE_F3, NOTE_F4, NOTE_D3, NOTE_D4, + NOTE_DS3, NOTE_DS4, 0, + 0, NOTE_DS4, NOTE_CS4, NOTE_D4, + NOTE_CS4, NOTE_DS4, + NOTE_DS4, NOTE_GS3, + NOTE_G3, NOTE_CS4, + NOTE_C4, NOTE_FS4, NOTE_F4, NOTE_E3, NOTE_AS4, NOTE_A4, + NOTE_GS4, NOTE_DS4, NOTE_B3, + NOTE_AS3, NOTE_A3, NOTE_GS3, + 0, 0, 0 +}; +//Underwolrd tempo +int underworld_tempo[] = { + 12, 12, 12, 12, + 12, 12, 6, + 3, + 12, 12, 12, 12, + 12, 12, 6, + 3, + 12, 12, 12, 12, + 12, 12, 6, + 3, + 12, 12, 12, 12, + 12, 12, 6, + 6, 18, 18, 18, + 6, 6, + 6, 6, + 6, 6, + 18, 18, 18, 18, 18, 18, + 10, 10, 10, + 10, 10, 10, + 3, 3, 3 +}; + +void setup(void) +{ + pinMode(5, OUTPUT);//buzzer + pinMode(13, OUTPUT);//led indicator when singing a note + +} +void loop() +{ + //sing the tunes + //sing(1); + sing(1); + sing(2); +} +int song = 0; + +void sing(int s) { + // iterate over the notes of the melody: + song = s; + if (song == 2) { + Serial.println(" 'Underworld Theme'"); + int size = sizeof(underworld_melody) / sizeof(int); + for (int thisNote = 0; thisNote < size; thisNote++) { + + // to calculate the note duration, take one second + // divided by the note type. + //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc. + int noteDuration = 1000 / underworld_tempo[thisNote]; + + buzz(melodyPin, underworld_melody[thisNote], noteDuration); + + // to distinguish the notes, set a minimum time between them. + // the note's duration + 30% seems to work well: + int pauseBetweenNotes = noteDuration * 1.30; + delay(pauseBetweenNotes); + + // stop the tone playing: + buzz(melodyPin, 0, noteDuration); + + } + + } else { + + Serial.println(" 'Mario Theme'"); + int size = sizeof(melody) / sizeof(int); + for (int thisNote = 0; thisNote < size; thisNote++) { + + // to calculate the note duration, take one second + // divided by the note type. + //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc. + int noteDuration = 1000 / tempo[thisNote]; + + buzz(melodyPin, melody[thisNote], noteDuration); + + // to distinguish the notes, set a minimum time between them. + // the note's duration + 30% seems to work well: + int pauseBetweenNotes = noteDuration * 1.30; + delay(pauseBetweenNotes); + + // stop the tone playing: + buzz(melodyPin, 0, noteDuration); + + } + } +} + +void buzz(int targetPin, long frequency, long length) { + digitalWrite(13, HIGH); + long delayValue = 1000000 / frequency / 2; // calculate the delay value between transitions + //// 1 second's worth of microseconds, divided by the frequency, then split in half since + //// there are two phases to each cycle + long numCycles = frequency * length / 1000; // calculate the number of cycles for proper timing + //// multiply frequency, which is really cycles per second, by the number of seconds to + //// get the total number of cycles to produce + for (long i = 0; i < numCycles; i++) { // for the calculated length of time... + digitalWrite(targetPin, HIGH); // write the buzzer pin high to push out the diaphram + delayMicroseconds(delayValue); // wait for the calculated delay value + digitalWrite(targetPin, LOW); // write the buzzer pin low to pull back the diaphram + delayMicroseconds(delayValue); // wait again or the calculated delay value + } + digitalWrite(13, LOW); + +} diff --git a/examples/Arduino-Music-Project/readme.md b/examples/Arduino-Music-Project/readme.md new file mode 100755 index 0000000..eb8082a --- /dev/null +++ b/examples/Arduino-Music-Project/readme.md @@ -0,0 +1,10 @@ +#Arduino Music Project + +**Note: this project is dormant (guess what that means). I will not be actively adding anything to this project, but i will take pull requests and stuff. Who knows though, I might come back** + +This project uses a nice header file called pitches.h from . Make sure you include it for the code to work. + +####Contents: +* Tetris Theme A +* Nyan Cat +* Add your own! (contributions are welcome) \ No newline at end of file