瀏覽代碼

was be created programm

Turkuman 1 年之前
當前提交
7881b5ce1b
共有 1 個文件被更改,包括 111 次插入0 次删除
  1. 111 0
      Happy_New_Year.cpp

+ 111 - 0
Happy_New_Year.cpp

@@ -0,0 +1,111 @@
+//////////////////////////////////////////////////////////////////////
+//                                                                  //
+// Programmname: Happy New Year(bearbeiten von python in c++)       //
+// Datum: 27.10.2023                                                //
+// Beschreibung: Es zählt von 10 bis 0 herunter und zeigt dann  die Nachricht Happy New Year!!! an.                 //
+//                                                                  //
+// 1. Turkuman Anna 5088159
+//                                                                  //
+//////////////////////////////////////////////////////////////////////
+
+//////////           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:";
+  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(startCount - 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
+}