|
#include "notes.h"
|
|
|
|
int tempo=144;
|
|
int melody[] = {
|
|
NOTE_E5, 4, NOTE_B4,8, NOTE_C5,8, NOTE_D5,4, NOTE_C5,8, NOTE_B4,8,
|
|
NOTE_A4, 4, NOTE_A4,8, NOTE_C5,8, NOTE_E5,4, NOTE_D5,8, NOTE_C5,8,
|
|
NOTE_B4, -4, NOTE_C5,8, NOTE_D5,4, NOTE_E5,4,
|
|
NOTE_C5, 4, NOTE_A4,4, NOTE_A4,8, NOTE_A4,4, NOTE_B4,8, NOTE_C5,8,
|
|
NOTE_D5, -4, NOTE_F5,8, NOTE_A5,4, NOTE_G5,8, NOTE_F5,8,
|
|
NOTE_E5, -4, NOTE_C5,8, NOTE_E5,4, NOTE_D5,8, NOTE_C5,8,
|
|
NOTE_B4, 4, NOTE_B4,8, NOTE_C5,8, NOTE_D5,4, NOTE_E5,4,
|
|
NOTE_C5, 4, NOTE_A4,4, NOTE_A4,4, REST, 4,
|
|
NOTE_E5, 4, NOTE_B4,8, NOTE_C5,8, NOTE_D5,4, NOTE_C5,8, NOTE_B4,8,
|
|
NOTE_A4, 4, NOTE_A4,8, NOTE_C5,8, NOTE_E5,4, NOTE_D5,8, NOTE_C5,8,
|
|
NOTE_B4, -4, NOTE_C5,8, NOTE_D5,4, NOTE_E5,4,
|
|
NOTE_C5, 4, NOTE_A4,4, NOTE_A4,8, NOTE_A4,4, NOTE_B4,8, NOTE_C5,8,
|
|
NOTE_D5, -4, NOTE_F5,8, NOTE_A5,4, NOTE_G5,8, NOTE_F5,8,
|
|
NOTE_E5, -4, NOTE_C5,8, NOTE_E5,4, NOTE_D5,8, NOTE_C5,8,
|
|
NOTE_B4, 4, NOTE_B4,8, NOTE_C5,8, NOTE_D5,4, NOTE_E5,4,
|
|
NOTE_C5, 4, NOTE_A4,4, NOTE_A4,4, REST, 4,
|
|
NOTE_E5,2, NOTE_C5,2,
|
|
NOTE_D5,2, NOTE_B4,2,
|
|
NOTE_C5,2, NOTE_A4,2,
|
|
NOTE_GS4,2, NOTE_B4,4, REST,8,
|
|
NOTE_E5,2, NOTE_C5,2,
|
|
NOTE_D5,2, NOTE_B4,2,
|
|
NOTE_C5,4, NOTE_E5,4, NOTE_A5,2,
|
|
NOTE_GS5,2,
|
|
};
|
|
|
|
int notes=sizeof(melody)/sizeof(melody[0])/2;
|
|
|
|
int wholenote = (60000 * 4) / tempo;
|
|
|
|
int divider = 0, noteDuration = 0;
|
|
|
|
void playTetris(){
|
|
for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) {
|
|
divider = melody[thisNote + 1];
|
|
if (divider > 0) {
|
|
noteDuration = (wholenote) / divider;
|
|
} else if (divider < 0) {
|
|
noteDuration = (wholenote) / abs(divider);
|
|
noteDuration *= 1.5;
|
|
}
|
|
tone(15, melody[thisNote], noteDuration*0.9);
|
|
delay(noteDuration);
|
|
noTone(15);
|
|
}
|
|
}
|