I'm trying to make a menu through serial monitor, but it always on a infinite loop... My question is where i call this function? On Setup or on Loop?
The menu:
int controle_opera = 0;
void menu() {
int i = -1;
do {
char opcao = '0円';
Serial.println("\nQual operação deseja realizar?");
Serial.println("\n1 - Cadastro");
Serial.println("\n2 - Validação");
Serial.println("\n3 - Deletar");
Serial.println("\n4 - Apagar database");
if (Serial.available()) {opcao = Serial.read();}
switch (opcao) {
case '1': controle_opera++;
i++;
break;
case '2': controle_opera += 2;
i++;
break;
case '3': controle_opera += 3;
i++;
break;
case '4': controle_opera += 4;
i++;
break;
default: Serial.println("Opção desconhecida, tente novamente!");
delay(100);
break;
}
} while(i != 0);
}
loop()
- but not that menu since it is fundamentally flawed in many many ways.