2013-12-29 14:27:14 +00:00
|
|
|
const unsigned int LED_PIN = 13;
|
2013-12-29 16:46:44 +00:00
|
|
|
const unsigned int NOTE_MULTIPLIER = 100;
|
|
|
|
|
|
|
|
const unsigned int QUARTER_NOTE = 8;
|
|
|
|
const unsigned int EIGHTH_NOTE = 4;
|
|
|
|
const unsigned int SIXTEENTH_NOTE = 2;
|
|
|
|
const unsigned int THIRTYSECOND_NOTE = 1;
|
|
|
|
|
|
|
|
int measure0[] = {-8, -8, -8, 2, 2, 2, 2, 0};
|
|
|
|
int measure1[] = {4, 2, 2, 4, 4, 4, -4, 2, 2, 2, 2, 0};
|
|
|
|
int measure2[] = {4, 2, 2, 4, 4, 4, -4, 2, 2, 2, 2, 0};
|
|
|
|
int measure3[] = {4, 4, 4, 4, 4, 4, 4, 4, 0};
|
|
|
|
int measure4[] = {4, 2, 2, 4, 4, 4, -4, 2, 2, 2, 2, 0};
|
|
|
|
int measure5[] = {4, 2, 2, 4, 4, 4, -4, 2, 2, 2, 2, 0};
|
|
|
|
int measure6[] = {4, 2, 2, 4, 4, 4, -4, 2, 2, 2, 2, 0};
|
|
|
|
int measure7[] = {4, 4, 4, 4, 4, 4, 4, 4, 0};
|
|
|
|
int measure8[] = {4, 2, 2, 4, 4, 4, -4, 2, 2, 2, 2, 0};
|
|
|
|
|
|
|
|
int measurePop[] = {4, -4, -8, -8, -8, 0};
|
|
|
|
|
|
|
|
void playNote(int note) {
|
|
|
|
if (note > 0) {
|
|
|
|
digitalWrite(LED_PIN, HIGH);
|
|
|
|
delay((NOTE_MULTIPLIER * note) / 2);
|
|
|
|
digitalWrite(LED_PIN, LOW);
|
|
|
|
delay((NOTE_MULTIPLIER * note) / 2);
|
|
|
|
} else if (note < 0) {
|
|
|
|
digitalWrite(LED_PIN, LOW);
|
|
|
|
delay(NOTE_MULTIPLIER * (-1 * note));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void playMeasure(int measure[]) {
|
2013-12-30 05:00:35 +00:00
|
|
|
for (int i = 0;; i++) {
|
2013-12-29 16:46:44 +00:00
|
|
|
int note = measure[i];
|
|
|
|
if (note == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
playNote(note);
|
|
|
|
}
|
|
|
|
}
|
2013-12-29 14:27:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
void setup() {
|
2013-12-29 16:46:44 +00:00
|
|
|
pinMode(LED_PIN, OUTPUT);
|
2013-12-29 14:27:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void loop() {
|
2013-12-29 16:46:44 +00:00
|
|
|
// int testMeasure[] = {2, 2, 2, 2, 2, -2, -2, -2, 0};
|
|
|
|
// playMeasure(testMeasure);
|
|
|
|
playMeasure(measure0);
|
|
|
|
playMeasure(measure1);
|
|
|
|
playMeasure(measure2);
|
|
|
|
playMeasure(measure3);
|
|
|
|
playMeasure(measure4);
|
|
|
|
playMeasure(measure5);
|
|
|
|
playMeasure(measure6);
|
|
|
|
playMeasure(measure7);
|
|
|
|
playMeasure(measure8);
|
|
|
|
playMeasure(measurePop);
|
2013-12-29 14:27:14 +00:00
|
|
|
}
|