From f4c7d85ebb33461b5b6a9e9ca88246d29d2ed90c Mon Sep 17 00:00:00 2001 From: Tim Wundenberg Date: Wed, 29 May 2019 21:34:19 +0200 Subject: [PATCH] initial commit --- Christmas.ino | 116 ++++++++++++++++++++++++++++++++++++++++++++++ Christmas.ino.bak | 77 ++++++++++++++++++++++++++++++ 2 files changed, 193 insertions(+) create mode 100644 Christmas.ino create mode 100644 Christmas.ino.bak diff --git a/Christmas.ino b/Christmas.ino new file mode 100644 index 0000000..a02ff3d --- /dev/null +++ b/Christmas.ino @@ -0,0 +1,116 @@ +#include + +const int + rs = 2, + en = 3, + d4 = 4, + d5 = 5, + d6 = 6, + d7 = 7; +LiquidCrystal lcd(rs, en, d4, d5, d6, d7); + +int length = 26; +char notes[] = "eeeeeeegcde fffffeeeeddedg"; +int beats[] = { 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2}; + +int tempo = 300; + +int LED1 = 12; +int LED2 = 11; +int LED3 = 10; +int SPEAKER = 8; +int BEATTIME = 100; + + +int zaehler = 0; +int maxLength = 17; +const int StringLength = 55; +char nachricht[StringLength] = "Ich schenke dir einen Gutschein fuer deinen Laptop :-)"; + + +void setup() { + lcd.begin(16, 2); + lcd.print("Frohe Weihnacht"); + + pinMode(LED1, OUTPUT); + pinMode(LED2, OUTPUT); + pinMode(LED3, OUTPUT); + pinMode(SPEAKER, OUTPUT); +} + + +void loop() { + for (int i = 0; i < length; i++) { + if (notes[i] == ' ') { + delay(beats[i] * tempo); // rest + } else { + playNote(notes[i], beats[i] * tempo); + } + + TurnOnLed(LED1); + TurnOnLed(LED2); + TurnOnLed(LED3); + + // pause between notes + delay(tempo / 2); + + + lcd.setCursor(0, 1); + if ((zaehler + maxLength) > StringLength) { + zaehler = 0; + } + else { + + +// if (zaehler == 0) +// delay (1000); + + for (int i = zaehler; i