////////////////////////////////////////////////////////////////////// // // // 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 }