|
@@ -1,101 +1,113 @@
|
|
|
-//////////////////////////////////////////////////////////////////////
|
|
|
-// //
|
|
|
-// 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
|
|
|
+//////////////////////////////////////////////////////////////////////
|
|
|
+// //
|
|
|
+// Programmname: Happy New Year //
|
|
|
+// Datum: 27.10.2023 //
|
|
|
+// Beschreibung: Es zählt von 10 bis 0 herunter und zeigt dann //
|
|
|
+// die Nachricht Happy New Year!!! an. //
|
|
|
+// //
|
|
|
+// 1. Autor: Nataliia Leonova 5088216 //
|
|
|
+// //
|
|
|
+// //
|
|
|
+//////////////////////////////////////////////////////////////////////
|
|
|
+
|
|
|
+////////// Inkludierte Header-Dateien //////////
|
|
|
+#include "Happy_New_Year.h"
|
|
|
+
|
|
|
+////////// Globale Variablen //////////
|
|
|
+
|
|
|
+
|
|
|
+////////// Setup-Funktion //////////
|
|
|
+
|
|
|
+void setup(void) { // put your setup code here, to run once:
|
|
|
+Serial.begin(BAUDRATE);
|
|
|
+ ////////// Lokale Variablen //////////
|
|
|
+
|
|
|
+
|
|
|
+ ////////// GPIO Setup //////////
|
|
|
+
|
|
|
+
|
|
|
+ ////////// 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:";
|
|
|
+ char stopCount = 10;
|
|
|
+ char startCount = 0;
|
|
|
+
|
|
|
+ ////////// Funktionsanweisungen //////////
|
|
|
+ for (char i = startCount; i < stopCount; i++) {
|
|
|
+ Serial.print(countMessage);
|
|
|
+ Serial.println(stopCount - i);
|
|
|
+ delay(1000);
|
|
|
+ }
|
|
|
+ Serial.print(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:";
|
|
|
+ char stopCount = 10;
|
|
|
+ char startCount = 0;
|
|
|
+
|
|
|
+ ////////// Funktionsanweisungen //////////
|
|
|
+ char i = startCount;
|
|
|
+ while (i < stopCount) {
|
|
|
+ Serial.print(countMessage);
|
|
|
+ Serial.println(stopCount - i);
|
|
|
+ delay(1000);
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ Serial.print(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 char stopCount = 10;
|
|
|
+ static char startCount = 0;
|
|
|
+
|
|
|
+
|
|
|
+ ////////// Funktionsanweisungen //////////
|
|
|
+ static char i = startCount;
|
|
|
+ if (i < stopCount) {
|
|
|
+ Serial.print(countMessage);
|
|
|
+ Serial.println(stopCount-i);
|
|
|
+ delay(1000);
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ else if (i == stopCount)
|
|
|
+ {
|
|
|
+ Serial.println(finalMessage);
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+
|
|
|
+ return; // Beenden der Unterfunktion
|
|
|
}
|