1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | String Eingabe = “”; void setup() { Serial.begin(9600); // auf serielle Verbindung warten while (!Serial); delay(1000); Serial.println(“Bitte gib eine Zahl ein:”); } void loop() { while (Serial.available() > 0) { char Zahl = Serial.read(); if (isDigit(Zahl)) { Eingabe = Eingabe + Zahl; } if (Zahl == ‘\n’) if (Eingabe.length() > 0) { { unsigned long Reihe = Eingabe.toInt(); ReiheAnzeigen(Reihe); Eingabe = “”; } } } } void ReiheAnzeigen(unsigned long Reihe) { Serial.print(“Einmaleins der ”); Serial.println(Reihe); for (int i = 1; i <= 10; i++) { Serial.print(i); Serial.print(“ * ”); Serial.print(Reihe); Serial.print(“ = ”); Serial.print(i * Reihe); Serial.println(); } Serial.println(“——————————-”); } |
Letzte Aktualisierung: