From 49a66e8980be9cd7a98ad44ff06fd900ce1e3a4b Mon Sep 17 00:00:00 2001 From: Max Lehmann Date: Thu, 10 Oct 2019 18:33:30 +0200 Subject: [PATCH] my first and weird tryouts on writing arduino code & my clapmusic code --- .../3.1_MelodyGenerator.ino | 61 ++++++++++++ .../max_sketch/3.1_MelodyGenerator/pitches.h | 93 +++++++++++++++++++ .../3.1_MelodyGenerator_weird.ino | 75 +++++++++++++++ .../3.1_MelodyGenerator_weird/pitches.h | 93 +++++++++++++++++++ sketches/max_sketch/clapexp2/clapexp2.ino | 46 +++++++++ 5 files changed, 368 insertions(+) create mode 100644 sketches/max_sketch/3.1_MelodyGenerator/3.1_MelodyGenerator.ino create mode 100644 sketches/max_sketch/3.1_MelodyGenerator/pitches.h create mode 100644 sketches/max_sketch/3.1_MelodyGenerator_weird/3.1_MelodyGenerator_weird.ino create mode 100644 sketches/max_sketch/3.1_MelodyGenerator_weird/pitches.h create mode 100644 sketches/max_sketch/clapexp2/clapexp2.ino 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]<