You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
911 B
C++

#include "pitches.h"
#define OUT 11
int melody[] = {
NOTE_C4,
NOTE_G5,
NOTE_A4,
NOTE_B4,
NOTE_B4,
NOTE_A5,
NOTE_B4,
NOTE_A5,
NOTE_A4,
NOTE_G5,
NOTE_G4,
NOTE_F5,
NOTE_G4,
NOTE_A4,
NOTE_G5,
NOTE_G4,
NOTE_G5,
NOTE_G4,
};
int noteDurations[] = {
1,
8, 8, 4, 4, 8, 8, 8, 8, 4,
4, 4, 4, 4, 4, 8, 8, 8
};
int NOTE;
void setup() {
Serial.begin(9600);
pinMode(OUT, OUTPUT);
}
void loop() {
for (int NOTE = 0; NOTE<18; NOTE++) {
int duration = 1000 / noteDurations[NOTE];
tone (11, melody[NOTE]<<Z/32, noteDurations);
int pause = duration * 1.30;
delay(pause);
noTone(11);
Serial.print(NOTE);
Serial.print("\t");
Serial.print(melody[NOTE]);
Serial.print("\t");
Serial.print(noteDurations[NOTE]);
Serial.print("\n");
}
}