TOTORO

so this little tune is a little happycode that I used at 4 o’clock in the morning sewing a skirt that is due at 9am earlier this week at a friends house. Instead of complaining about why we are still awake sewing, I decided to use this tune as a positive response whenever we need a little boost before breaking down and refusing to finish our garment (just because coffee no longer suffice to the overdosed fashion student).

Sound link –>  http://youtu.be/JGUlDB8K5LM

Here is my code though….

#include “pitches.h”
int melody[] = {
NOTE_G4,NOTE_E4,NOTE_C4, NOTE_G4,NOTE_F4,NOTE_D4, NOTE_F4,NOTE_D4,NOTE_B3, NOTE_F4,NOTE_E4,NOTE_C4};

int noteDurations[]={
2,4,4, 4,2,2, 2,4,4, 4,2,4};

void setup(){
// iterate over the notes of the melody:
for (int thisNote = 0; thisNote < 13; thisNote++) { //LOOP (if the note is 0, play the first note. thisNote<13 means dont exceed the 12th note

// 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(8, melody[thisNote],noteDuration); // (pin no, melody array, noteDuration)

// the note’s duration + 30% seems to work well:
int pauseBetweenNotes = noteDuration * 1.30; //
delay(pauseBetweenNotes);
// stop the tone playing:
noTone(8);
}
}

void loop() {
// no need to repeat the melody.
}

Leave a Reply

Your email address will not be published.