Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Sacrifices were made
- #include "sp.h" ///same as pitches.h
- #include <toneAC.h>
- // notes in the melody:
- int melody[] = {
- //NOTE_DS6, NOTE_E6, NOTE_FS6, NOTE_B6, NOTE_DS6, NOTE_E6, NOTE_FS6, NOTE_B6, NOTE_CS7, NOTE_DS7, NOTE_CS7, NOTE_AS6, NOTE_B6, NOTE_FS6, NOTE_DS6, NOTE_E6, NOTE_FS6, NOTE_B6, NOTE_CS7, NOTE_AS6, NOTE_B6, NOTE_CS7, NOTE_E7, NOTE_DS7, NOTE_E7, NOTE_CS7, NOTE_FS6, NOTE_GS6, NOTE_DS6, NOTE_DS6,0,NOTE_B0, NOTE_D6, NOTE_CS6, NOTE_B0,0,NOTE_B7, NOTE_CS7, NOTE_D6, NOTE_D6, NOTE_CS6, NOTE_B0, NOTE_CS6, NOTE_DS6, NOTE_FS6, NOTE_GS6, NOTE_DS6, NOTE_FS6, NOTE_CS6, NOTE_DS6, NOTE_B0, NOTE_CS6, NOTE_B0, NOTE_DS6, NOTE_FS6, NOTE_GS6, NOTE_DS6, NOTE_FS6, NOTE_CS6, NOTE_DS6, NOTE_B0, NOTE_D6, NOTE_DS6, NOTE_D6, NOTE_CS6, NOTE_B0, NOTE_CS6, NOTE_D6, NOTE_B0, NOTE_CS6, NOTE_DS6, NOTE_FS6, NOTE_CS6, NOTE_DS6, NOTE_CS6, NOTE_B0, NOTE_CS7, NOTE_B7, NOTE_CS7, NOTE_FS6, NOTE_GS6, NOTE_DS6, NOTE_DS6,0,NOTE_B0, NOTE_D6, NOTE_CS6, NOTE_B0,0,NOTE_B7, NOTE_CS7, NOTE_D6, NOTE_D6, NOTE_CS6, NOTE_B0, NOTE_CS6, NOTE_DS6, NOTE_FS6, NOTE_GS6, NOTE_DS6, NOTE_FS6, NOTE_CS6, NOTE_DS6, NOTE_B0, NOTE_CS6, NOTE_B0, NOTE_DS6, NOTE_FS6, NOTE_GS6, NOTE_DS6, NOTE_FS6, NOTE_CS6, NOTE_DS6, NOTE_B0, NOTE_D6, NOTE_DS6, NOTE_D6, NOTE_CS6, NOTE_B0, NOTE_CS6, NOTE_D6, NOTE_B0, NOTE_CS6, NOTE_DS6, NOTE_FS6, NOTE_CS6, NOTE_DS6, NOTE_CS6, NOTE_B0, NOTE_CS7, NOTE_B7, NOTE_CS7, NOTE_B7, NOTE_FS1, NOTE_GS1, NOTE_B7, NOTE_FS1, NOTE_GS1, NOTE_B0, NOTE_CS6, NOTE_DS6, NOTE_B0, NOTE_E6, NOTE_DS6, NOTE_E6, NOTE_FS6, NOTE_B7, NOTE_B7, NOTE_FS1, NOTE_GS1, NOTE_B0, NOTE_FS1, NOTE_E6, NOTE_DS6, NOTE_CS6, NOTE_B0, NOTE_FS1, NOTE_DS1, NOTE_E0, NOTE_FS1, NOTE_B7, NOTE_FS1, NOTE_GS1, NOTE_B7, NOTE_FS1, NOTE_GS1, NOTE_B0, NOTE_B0, NOTE_CS6, NOTE_DS6, NOTE_B0, NOTE_FS1, NOTE_GS1, NOTE_FS1, NOTE_B7, NOTE_B0, NOTE_AS1, NOTE_B0, NOTE_FS1, NOTE_GS1, NOTE_B0, NOTE_E6, NOTE_DS6, NOTE_E6, NOTE_FS6, NOTE_B7, NOTE_AS1, NOTE_B7, NOTE_FS1, NOTE_GS1, NOTE_B7, NOTE_FS1, NOTE_GS1, NOTE_B0, NOTE_CS6, NOTE_DS6, NOTE_B0, NOTE_E6, NOTE_DS6, NOTE_E6, NOTE_FS6, NOTE_B7, NOTE_B7, NOTE_FS1, NOTE_GS1, NOTE_B0, NOTE_FS1, NOTE_E6, NOTE_DS6, NOTE_CS6, NOTE_B0, NOTE_FS1, NOTE_DS1, NOTE_E0, NOTE_FS1, NOTE_B7, NOTE_FS1, NOTE_GS1, NOTE_B7, NOTE_FS1, NOTE_GS1, NOTE_B0, NOTE_B0, NOTE_CS6, NOTE_DS6, NOTE_B0, NOTE_FS1, NOTE_GS1, NOTE_FS1, NOTE_B7, NOTE_B0, NOTE_AS1, NOTE_B0, NOTE_FS1, NOTE_GS1, NOTE_B0, NOTE_E6, NOTE_DS6, NOTE_E6, NOTE_FS6, NOTE_B7, NOTE_CS7, NOTE_DS3, NOTE_E3
- NOTE_DS6, NOTE_E6, NOTE_FS6, NOTE_B6, NOTE_DS6, NOTE_E6, NOTE_FS6, NOTE_B6, NOTE_CS7, NOTE_DS7, NOTE_CS7, NOTE_AS6, NOTE_B6, NOTE_FS6, NOTE_DS6, NOTE_E6, NOTE_FS6, NOTE_B6, NOTE_CS7, NOTE_AS6, NOTE_B6, NOTE_CS7, NOTE_E7, NOTE_DS7, NOTE_E7, NOTE_CS7, NOTE_FS6, NOTE_GS6, NOTE_DS6, NOTE_DS6,0,NOTE_B0, NOTE_D6, NOTE_CS6, NOTE_B0,0,NOTE_B7, NOTE_CS7, NOTE_D6, NOTE_D6, NOTE_CS6, NOTE_B0, NOTE_CS6, NOTE_DS6, NOTE_FS6, NOTE_GS6, NOTE_DS6, NOTE_FS6, NOTE_CS6, NOTE_DS6, NOTE_B0, NOTE_CS6, NOTE_B0, NOTE_DS6, NOTE_FS6, NOTE_GS6, NOTE_DS6, NOTE_FS6, NOTE_CS6, NOTE_DS6, NOTE_B0, NOTE_D6, NOTE_DS6, NOTE_D6, NOTE_CS6, NOTE_B0, NOTE_CS6, NOTE_D6, NOTE_B0, NOTE_CS6, NOTE_DS6, NOTE_FS6, NOTE_CS6, NOTE_DS6, NOTE_CS6, NOTE_B0, NOTE_CS7, NOTE_B7, NOTE_CS7, NOTE_FS6, NOTE_GS6, NOTE_DS6, NOTE_DS6,0,NOTE_B0, NOTE_D6, NOTE_CS6, NOTE_B0,0,NOTE_B7, NOTE_CS7, NOTE_D6, NOTE_D6, NOTE_CS6, NOTE_B0//, NOTE_CS6, NOTE_DS6, NOTE_FS6, NOTE_GS6, NOTE_DS6, NOTE_FS6, NOTE_CS6, NOTE_DS6, NOTE_B0, NOTE_CS6, NOTE_B0, NOTE_DS6, NOTE_FS6, NOTE_GS6, NOTE_DS6, NOTE_FS6, NOTE_CS6, NOTE_DS6, NOTE_B0, NOTE_D6, NOTE_DS6, NOTE_D6, NOTE_CS6, NOTE_B0, NOTE_CS6, NOTE_D6, NOTE_B0, NOTE_CS6, NOTE_DS6, NOTE_FS6, NOTE_CS6, NOTE_DS6, NOTE_CS6, NOTE_B0, NOTE_CS7, NOTE_B7, NOTE_CS7, NOTE_B7, NOTE_FS1, NOTE_GS1, NOTE_B7, NOTE_FS1, NOTE_GS1, NOTE_B0, NOTE_CS6, NOTE_DS6, NOTE_B0, NOTE_E6, NOTE_DS6, NOTE_E6, NOTE_FS6, NOTE_B7, NOTE_B7, NOTE_FS1, NOTE_GS1, NOTE_B0, NOTE_FS1, NOTE_E6, NOTE_DS6, NOTE_CS6, NOTE_B0, NOTE_FS1, NOTE_DS1, NOTE_E0, NOTE_FS1, NOTE_B7, NOTE_FS1, NOTE_GS1, NOTE_B7, NOTE_FS1, NOTE_GS1, NOTE_B0, NOTE_B0, NOTE_CS6, NOTE_DS6, NOTE_B0, NOTE_FS1, NOTE_GS1, NOTE_FS1, NOTE_B7, NOTE_B0, NOTE_AS1, NOTE_B0, NOTE_FS1, NOTE_GS1, NOTE_B0, NOTE_E6, NOTE_DS6, NOTE_E6, NOTE_FS6, NOTE_B7, NOTE_AS1, NOTE_B7, NOTE_FS1, NOTE_GS1, NOTE_B7, NOTE_FS1, NOTE_GS1, NOTE_B0, NOTE_CS6, NOTE_DS6, NOTE_B0, NOTE_E6, NOTE_DS6, NOTE_E6, NOTE_FS6, NOTE_B7, NOTE_B7, NOTE_FS1, NOTE_GS1, NOTE_B0, NOTE_FS1, NOTE_E6, NOTE_DS6, NOTE_CS6, NOTE_B0, NOTE_FS1, NOTE_DS1, NOTE_E0, NOTE_FS1, NOTE_B7, NOTE_FS1, NOTE_GS1, NOTE_B7, NOTE_FS1, NOTE_GS1, NOTE_B0, NOTE_B0, NOTE_CS6, NOTE_DS6, NOTE_B0, NOTE_FS1, NOTE_GS1, NOTE_FS1, NOTE_B7, NOTE_B0, NOTE_AS1, NOTE_B0, NOTE_FS1, NOTE_GS1, NOTE_B0, NOTE_E6, NOTE_DS6, NOTE_E6, NOTE_FS6, NOTE_B7, NOTE_CS7, NOTE_DS3, NOTE_E3
- //NOTE_DS6, NOTE_E6, NOTE_FS6, NOTE_B6, NOTE_DS6, NOTE_E6, NOTE_FS6, NOTE_B6, NOTE_CS7, NOTE_DS7, NOTE_CS7, NOTE_AS6, NOTE_B6, NOTE_FS6, NOTE_DS6, NOTE_E6, NOTE_FS6, NOTE_B6, NOTE_CS7, NOTE_AS6, NOTE_B6, NOTE_CS7, NOTE_E7, NOTE_DS7, NOTE_E7, NOTE_CS7, NOTE_FS6, NOTE_GS6, NOTE_DS6, NOTE_DS6,0,NOTE_B0, NOTE_D6, NOTE_CS6, NOTE_B0,0,NOTE_B7, NOTE_CS7, NOTE_D6, NOTE_D6, NOTE_CS6, NOTE_B0, NOTE_CS6, NOTE_DS6, NOTE_FS6, NOTE_GS6, NOTE_DS6, NOTE_FS6, NOTE_CS6, NOTE_DS6, NOTE_B0, NOTE_CS6, NOTE_B0, NOTE_DS6, NOTE_FS6, NOTE_GS6, NOTE_DS6, NOTE_FS6, NOTE_CS6, NOTE_DS6, NOTE_B0, NOTE_D6, NOTE_DS6, NOTE_D6, NOTE_CS6, NOTE_B0, NOTE_CS6, NOTE_D6, NOTE_B0, NOTE_CS6, NOTE_DS6, NOTE_FS6, NOTE_CS6, NOTE_DS6, NOTE_CS6, NOTE_B0, NOTE_CS7, NOTE_B7, NOTE_CS7, NOTE_FS6, NOTE_GS6, NOTE_DS6, NOTE_DS6,0,NOTE_B0, NOTE_D6, NOTE_CS6, NOTE_B0,0,NOTE_B7, NOTE_CS7, NOTE_D6, NOTE_D6, NOTE_CS6, NOTE_B0//, NOTE_CS6, NOTE_DS6, NOTE_FS6, NOTE_GS6, NOTE_DS6, NOTE_FS6, NOTE_CS6, NOTE_DS6, NOTE_B0, NOTE_CS6, NOTE_B0, NOTE_DS6, NOTE_FS6, NOTE_GS6, NOTE_DS6, NOTE_FS6, NOTE_CS6, NOTE_DS6, NOTE_B0, NOTE_D6, NOTE_DS6, NOTE_D6, NOTE_CS6, NOTE_B0, NOTE_CS6, NOTE_D6, NOTE_B0, NOTE_CS6, NOTE_DS6, NOTE_FS6, NOTE_CS6, NOTE_DS6, NOTE_CS6, NOTE_B0, NOTE_CS7, NOTE_B7, NOTE_CS7, NOTE_B7, NOTE_FS1, NOTE_GS1, NOTE_B7, NOTE_FS1, NOTE_GS1, NOTE_B0, NOTE_CS6, NOTE_DS6, NOTE_B0, NOTE_E6, NOTE_DS6, NOTE_E6, NOTE_FS6, NOTE_B7, NOTE_B7, NOTE_FS1, NOTE_GS1, NOTE_B0, NOTE_FS1, NOTE_E6, NOTE_DS6, NOTE_CS6, NOTE_B0, NOTE_FS1, NOTE_DS1, NOTE_E0, NOTE_FS1, NOTE_B7, NOTE_FS1, NOTE_GS1, NOTE_B7, NOTE_FS1, NOTE_GS1, NOTE_B0, NOTE_B0, NOTE_CS6, NOTE_DS6, NOTE_B0, NOTE_FS1, NOTE_GS1, NOTE_FS1, NOTE_B7, NOTE_B0, NOTE_AS1, NOTE_B0, NOTE_FS1, NOTE_GS1, NOTE_B0, NOTE_E6, NOTE_DS6, NOTE_E6, NOTE_FS6, NOTE_B7, NOTE_AS1, NOTE_B7, NOTE_FS1, NOTE_GS1, NOTE_B7, NOTE_FS1, NOTE_GS1, NOTE_B0, NOTE_CS6, NOTE_DS6, NOTE_B0, NOTE_E6, NOTE_DS6, NOTE_E6, NOTE_FS6, NOTE_B7, NOTE_B7, NOTE_FS1, NOTE_GS1, NOTE_B0, NOTE_FS1, NOTE_E6, NOTE_DS6, NOTE_CS6, NOTE_B0, NOTE_FS1, NOTE_DS1, NOTE_E0, NOTE_FS1, NOTE_B7, NOTE_FS1, NOTE_GS1, NOTE_B7, NOTE_FS1, NOTE_GS1, NOTE_B0, NOTE_B0, NOTE_CS6, NOTE_DS6, NOTE_B0, NOTE_FS1, NOTE_GS1, NOTE_FS1, NOTE_B7, NOTE_B0, NOTE_AS1, NOTE_B0, NOTE_FS1, NOTE_GS1, NOTE_B0, NOTE_E6, NOTE_DS6, NOTE_E6, NOTE_FS6, NOTE_B7, NOTE_CS7, NOTE_DS3, NOTE_E3
- };
- void comments(){
- Serial.println("Comments in code lol");
- //sharp frq formula: NS=N+(i*2)+(i-1)+1 (i=itteration starting at 1) its close, but not quiet right.
- //58=55+(1*2)+(1-1)+1 == 58 //cool it works lol
- //117=110+(2*2)+(2-1)+1 ==116 !=117 hmmm
- //233=220+(3*2)+(3-1)+1 ==229 !=233
- //durration Note (itteration?) Number pause (looks like)
- //ok I typoed transcribing set NOTE_Note0==NOTE_Note1 where not otherwise defined
- //now to underp the array see line abouve
- // char _NYANLIB_RTTTL_SONG_NYAN[] ="nyan cat:d=4,o=4,b=120:
- // NOTE_DS6, NOTE_E6, NOTE_FS6, NOTE_B6, NOTE_DS6,
- // NOTE_E6, NOTE_FS6, NOTE_B6, NOTE_CS7, NOTE_DS7,
- // NOTE_CS7, NOTE_AS6, NOTE_B6, NOTE_FS6, NOTE_DS6,
- // NOTE_E6, NOTE_FS6, NOTE_B6, NOTE_CS7, NOTE_AS6,
- // NOTE_B6, NOTE_CS7, NOTE_E7, NOTE_DS7, NOTE_E7,
- // NOTE_CS7, NOTE_FS6, NOTE_GS6, NOTE_DS6, NOTE_DS6,0,NOTE_B0,
- // NOTE_D6, NOTE_CS6, NOTE_B0,0,NOTE_B7, NOTE_CS7, NOTE_D6,
- // NOTE_D6, NOTE_CS6, NOTE_B0, NOTE_CS6, NOTE_DS6,
- // NOTE_FS6, NOTE_GS6, NOTE_DS6, NOTE_FS6, NOTE_CS6,
- // NOTE_DS6, NOTE_B0, NOTE_CS6, NOTE_B0, NOTE_DS6, NOTE_FS6,
- // NOTE_GS6, NOTE_DS6, NOTE_FS6, NOTE_CS6, NOTE_DS6, NOTE_B0,
- // NOTE_D6, NOTE_DS6, NOTE_D6, NOTE_CS6, NOTE_B0,
- // NOTE_CS6, NOTE_D6, NOTE_B0, NOTE_CS6, NOTE_DS6, NOTE_FS6,
- // NOTE_CS6, NOTE_DS6, NOTE_CS6, NOTE_B0, NOTE_CS7, NOTE_B7,
- // NOTE_CS7, NOTE_FS6, NOTE_GS6, NOTE_DS6, NOTE_DS6,0,NOTE_B0,
- // NOTE_D6, NOTE_CS6, NOTE_B0,0,NOTE_B7, NOTE_CS7, NOTE_D6,
- // NOTE_D6, NOTE_CS6, NOTE_B0, NOTE_CS6, NOTE_DS6,
- // NOTE_FS6, NOTE_GS6, NOTE_DS6, NOTE_FS6, NOTE_CS6,
- // NOTE_DS6, NOTE_B0, NOTE_CS6, NOTE_B0, NOTE_DS6, NOTE_FS6,
- // NOTE_GS6, NOTE_DS6, NOTE_FS6, NOTE_CS6, NOTE_DS6, NOTE_B0,
- // NOTE_D6, NOTE_DS6, NOTE_D6, NOTE_CS6, NOTE_B0,
- // NOTE_CS6, NOTE_D6, NOTE_B0, NOTE_CS6, NOTE_DS6,
- // NOTE_FS6, NOTE_CS6, NOTE_DS6, NOTE_CS6, NOTE_B0,
- // NOTE_CS7, NOTE_B7, NOTE_CS7, NOTE_B7, NOTE_FS1,
- // NOTE_GS1, NOTE_B7, NOTE_FS1, NOTE_GS1, NOTE_B0,
- // NOTE_CS6, NOTE_DS6, NOTE_B0, NOTE_E6, NOTE_DS6, NOTE_E6,
- // NOTE_FS6, NOTE_B7, NOTE_B7, NOTE_FS1, NOTE_GS1, NOTE_B0, NOTE_FS1,
- // NOTE_E6, NOTE_DS6, NOTE_CS6, NOTE_B0, NOTE_FS1,
- // NOTE_DS1, NOTE_E0, NOTE_FS1, NOTE_B7, NOTE_FS1, NOTE_GS1, NOTE_B7,
- // NOTE_FS1, NOTE_GS1, NOTE_B0, NOTE_B0, NOTE_CS6, NOTE_DS6, NOTE_B0,
- // NOTE_FS1, NOTE_GS1, NOTE_FS1, NOTE_B7, NOTE_B0, NOTE_AS1, NOTE_B0,
- // NOTE_FS1, NOTE_GS1, NOTE_B0, NOTE_E6, NOTE_DS6, NOTE_E6,
- // NOTE_FS6, NOTE_B7, NOTE_AS1, NOTE_B7, NOTE_FS1, NOTE_GS1, NOTE_B7,
- // NOTE_FS1, NOTE_GS1, NOTE_B0, NOTE_CS6, NOTE_DS6, NOTE_B0,
- // NOTE_E6, NOTE_DS6, NOTE_E6, NOTE_FS6, NOTE_B7, NOTE_B7,
- // NOTE_FS1, NOTE_GS1, NOTE_B0, NOTE_FS1, NOTE_E6, NOTE_DS6,
- // NOTE_CS6, NOTE_B0, NOTE_FS1, NOTE_DS1, NOTE_E0, NOTE_FS1, NOTE_B7,
- // NOTE_FS1, NOTE_GS1, NOTE_B7, NOTE_FS1, NOTE_GS1, NOTE_B0, NOTE_B0,
- // NOTE_CS6, NOTE_DS6, NOTE_B0, NOTE_FS1, NOTE_GS1,
- // NOTE_FS1, NOTE_B7, NOTE_B0, NOTE_AS1, NOTE_B0, NOTE_FS1,
- // NOTE_GS1, NOTE_B0, NOTE_E6, NOTE_DS6, NOTE_E6,
- // NOTE_FS6, NOTE_B7, NOTE_CS7, NOTE_DS3, NOTE_E3
- }
- // note durations: 4 = quarter note, 8 = eighth note, etc.:
- int noteDurations[] = {
- //needs work
- 4, 8, 8, 4, 4, 4, 4, 4
- // 2, 10, 10, 5, 3, 5, 3, 7
- };
- void nyanclear(){
- Serial.write(12); //ascii form feed a line breaking character doesnt do what I want it to in the arduino terminal, but it may in the linux term
- }
- void nyan(){
- for (int thisNote = 0; thisNote < 8; 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*.6 / noteDurations[thisNote];
- tone(8, 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.40;
- delay(pauseBetweenNotes);
- // stop the tone playing:
- noTone(8);
- }
- }
- void setup() {
- Serial.begin(9600);
- // nyanyan(); // :( exceeds memory... 3 frames and all the notes FFS
- //maybe put the lines in an array
- String nyanString= " o * o +";
- nyanString += "+ o + * \n";
- nyanString += " + \n";
- nyanString += "o + + + \n";
- nyanString += " o o * O \n";
- nyanString += ".~~~.___.~~~ ,-------. o \n";
- nyanString += "~~.___.~~~.__| /\\_/\\ \n";
- nyanString += ".~~~.___.~~~ |___( ^ .^) + + \n";
- nyanString += "~~.___.~~~.___/ / / /` o\n";
- nyanString += " o o + o \n";
- nyanString += "+ * \n";
- nyanString += " o o o + \n";
- nyanString += "o + \n";
- nyanString += " + 0 o * o\n";
- Serial.println(nyanString);
- }
- void loop() {
- nyan();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement