Ein­mal­eins­rei­hen Seri­el­ler Monitor

String Eingabe = "";

void setup()
{
  Serial.begin(9600);
}

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: 24. Jul 2023 @ 10:42