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