How to use the Serial Monitor Send button...?

Hello
For purposes of tests I´m using the following code:
In the loop()

if (Serial.available()) keyboard();

and

void keyboard() {
static int modeAlt = mode;
  switch (Serial.read())
  {
    case '1': mode = One; break;
    case '2': mode = Two break;
    case '3': mode = Three; break;
    case '4': mode = Four; break;
  }
  if (modeAlt != mode) modeAlt = mode, Serial.println(modeTxt[mode]);
}
1 Like