|
@@ -0,0 +1,101 @@
|
|
|
+//////////////////////////////////////////////////////////////////////
|
|
|
+// //
|
|
|
+// Programmname: <Happy New Year> //
|
|
|
+// Datum: 27.10.2023 //
|
|
|
+// Beschreibung: <Das Programm zählt die Zeit fürs neue Jahr > //
|
|
|
+// //
|
|
|
+// 1. Autor: Svitlana Sokulieva, Matrikel, 5088203. //
|
|
|
+// //
|
|
|
+// //
|
|
|
+//////////////////////////////////////////////////////////////////////
|
|
|
+
|
|
|
+////////// Inkludierte Header-Dateien //////////
|
|
|
+#include "Happy_New_Year.h"
|
|
|
+
|
|
|
+////////// Globale Variablen //////////
|
|
|
+
|
|
|
+
|
|
|
+////////// Setup-Funktion //////////
|
|
|
+
|
|
|
+void setup(void) { // put your setup code here, to run once:
|
|
|
+
|
|
|
+ ////////// Lokale Variablen //////////
|
|
|
+
|
|
|
+ ////////// GPIO Setup //////////
|
|
|
+Serial.begin(BAUDRATE);
|
|
|
+ ////////// Einmalige Anweisungen //////////
|
|
|
+happy_new_year_for();
|
|
|
+happy_new_year_while();
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+////////// Loop-Funktion //////////
|
|
|
+
|
|
|
+void loop(void) { // put your main code here, to run repeatedly:
|
|
|
+
|
|
|
+ ////////// Lokale Variablen //////////
|
|
|
+
|
|
|
+ ////////// Hauptprogramm //////////
|
|
|
+happy_new_year_if();
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+////////// Unterfunktionen / ISR //////////
|
|
|
+
|
|
|
+void happy_new_year_for(void) { // "for" solution for "Happy New Year"
|
|
|
+
|
|
|
+ ////////// Lokale Variablen //////////
|
|
|
+char finalMessage[] = "Happy New Year!!!";
|
|
|
+char countMessage[] = "Countdown: ";
|
|
|
+int stopCount = 10 ;
|
|
|
+ ////////// Funktionsanweisungen //////////
|
|
|
+for(int i=0; i< stopCount;i++){
|
|
|
+ Serial.print(countMessage);
|
|
|
+ Serial.println(stopCount-i);
|
|
|
+ delay(1000);
|
|
|
+}
|
|
|
+ Serial.println(finalMessage);
|
|
|
+
|
|
|
+ return; // Beenden der Unterfunktion
|
|
|
+}
|
|
|
+
|
|
|
+void happy_new_year_while(void) { // "while" solution for "Happy New Year"
|
|
|
+
|
|
|
+ ////////// Lokale Variablen //////////
|
|
|
+char finalMessage[] = "Happy New Year!!!";
|
|
|
+char countMessage[] = "Countdown: ";
|
|
|
+int stopCount = 10 ;
|
|
|
+ ////////// Funktionsanweisungen //////////
|
|
|
+while(stopCount>0){
|
|
|
+ Serial.print(countMessage);
|
|
|
+ Serial.println(stopCount);
|
|
|
+ stopCount=stopCount-1;
|
|
|
+ delay(1000);
|
|
|
+}
|
|
|
+
|
|
|
+ Serial.println(finalMessage);
|
|
|
+
|
|
|
+ return; // Beenden der Unterfunktion
|
|
|
+}
|
|
|
+
|
|
|
+void happy_new_year_if(void) { // "if/else" solution for "Happy New Year"
|
|
|
+
|
|
|
+ ////////// Lokale Variablen //////////
|
|
|
+static char finalMessage[] = "Happy New Year!!!";
|
|
|
+static char countMessage[] = "Countdown: ";
|
|
|
+static int stopCount = 10 ;
|
|
|
+static int startCount = 0 ;
|
|
|
+ ////////// Funktionsanweisungen //////////
|
|
|
+ if (startCount < stopCount) {
|
|
|
+ Serial.print(countMessage);
|
|
|
+ Serial.println(stopCount);
|
|
|
+ stopCount--;
|
|
|
+ delay(1000);
|
|
|
+ } else if (startCount == stopCount) {
|
|
|
+ Serial.println(finalMessage);
|
|
|
+ startCount++;
|
|
|
+ }
|
|
|
+
|
|
|
+ return; // Beenden der Unterfunktion
|
|
|
+}
|