Beep Boop Lee

The peizo I have sounds pretty poor at all octaves unfortunately. There’s hardly any discernible difference between notes and this translates even worse being picked up by my computers microphone. Ah well, check out the video and my code is posted below.

#include “pitches.h”

// notes in the melody:
int hello[] = {
NOTE_F5, NOTE_G5, NOTE_A5, NOTE_B5, NOTE_C6,0, NOTE_A5,0,0,0};
// note durations: 4 = quarter note, 8 = eighth note, etc.:
int helloDurations[] = {
16, 16, 16, 16 ,8,4,4,1,1,1};

int goodbye[] = {
NOTE_E4, NOTE_D4, NOTE_C4, 0,0,0};
int goodbyeDurations[] = {
2,4,1,1,1,1};

int happy[] = {
NOTE_E7, NOTE_D7, NOTE_A7, NOTE_D7, NOTE_A7, NOTE_D7, NOTE_A7, NOTE_G7,0,0,0};
int happyDurations[] = {
8,16,16,16,16,16,16,2,1,1,1};

int sad[] = {
NOTE_B4, 0, NOTE_G4, 0, NOTE_E4, 0, NOTE_D4,0,0,0};
int sadDurations[] = {
2,4,2,4,2,4,1,1,1,1};

int yes[] = {
NOTE_CS7,0,NOTE_E7,0,0,0};
int yesDurations[] = {
8,16,8,1,1,1};

int no[] = {
NOTE_DS5,0,NOTE_DS5,0,0,0};
int noDurations[] = {
8,16,8,1,1,1};

int dyeing[] = {
NOTE_AS4, NOTE_E4, NOTE_AS4, NOTE_E4, NOTE_AS4, NOTE_E4, NOTE_AS4, NOTE_E4, NOTE_AS4, 0,0,0};
int dyeingDurations[] = {
8,8,8,8,8,8,8,8,8,0,0,0};

void setup() {
// iterate over the notes of the melody:

for (int thisNote = 0; thisNote < 10; thisNote++) {
int helloDuration = 1000/helloDurations[thisNote];
tone(8, hello[thisNote],helloDuration);
int pauseBetweenNotes = helloDuration * 1.30;
delay(pauseBetweenNotes);
}

for (int thisNote = 0; thisNote < 6; thisNote++) {
int goodbyeDuration = 1000/goodbyeDurations[thisNote];
tone(8, goodbye[thisNote],goodbyeDuration);
int pauseBetweenNotes = goodbyeDuration * 1.30;
delay(pauseBetweenNotes);
}

for (int thisNote = 0; thisNote < 11; thisNote++) {
int happyDuration = 1000/happyDurations[thisNote];
tone(8, happy[thisNote],happyDuration);
int pauseBetweenNotes = happyDuration * 1.30;
delay(pauseBetweenNotes);
}

for (int thisNote = 0; thisNote < 10; thisNote++) {
int sadDuration = 1000/sadDurations[thisNote];
tone(8, sad[thisNote],sadDuration);
int pauseBetweenNotes = sadDuration * 1.30;
delay(pauseBetweenNotes);
}

for (int thisNote = 0; thisNote < 6; thisNote++) {
int yesDuration = 1000/yesDurations[thisNote];
tone(8, yes[thisNote],yesDuration);
int pauseBetweenNotes = yesDuration * 1.30;
delay(pauseBetweenNotes);
}

for (int thisNote = 0; thisNote < 6; thisNote++) {
int noDuration = 1000/noDurations[thisNote];
tone(8, no[thisNote],noDuration);
int pauseBetweenNotes = noDuration * 1.30;
delay(pauseBetweenNotes);
}

for (int thisNote = 0; thisNote < 12; thisNote++) {
int dyeingDuration = 1000/dyeingDurations[thisNote];
tone(8, dyeing[thisNote],dyeingDuration);
int pauseBetweenNotes = dyeingDuration * 1.30;
delay(pauseBetweenNotes);
}
}

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