diff --git a/sketches/max_sketch/3.1_MelodyGenerator/3.1_MelodyGenerator.ino b/sketches/max_sketch/3.1_MelodyGenerator/3.1_MelodyGenerator.ino new file mode 100644 index 0000000..f5b1b08 --- /dev/null +++ b/sketches/max_sketch/3.1_MelodyGenerator/3.1_MelodyGenerator.ino @@ -0,0 +1,61 @@ +#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]<