# Sending AT commands via switch case in Arduino

Is this the proper use for switch case? I am looking to make a simple utility for reporting back Wireless AP info, Baud Rate, and Mode of a ESP8266 module.

When the program loads it gives the user a small menu of option and based on the input of the user (1,2 or 3) it will run the associated AT command stored as a variable in the code.

Will this work as is? Or am I missing something to send the command and get the data back?

void loop() {

if (Serial.available() > 0) {
Serial.flush();

switch (input) {
case '1':
Serial.println(baud);
break;

case '2':
Serial.println(wap);
break;

case '3':
Serial.println(amode);
break;

default:
Serial.print("'");
Serial.print((char)input);
Serial.println("' is not a command!");
}
}
}


The baud, wap, and amode commands are setup as follows:

const char* wap = "AT+CWLAP";
const char* baud = "AT+CIOBAUD";
const char* amode = "AT+CWMODE";

• I am stuck. The code works to send the commands to the serial monitor but it's not returning the information it should. It just shows the command. – Das Nuk Mar 5 '18 at 22:12
• I can post my full code if that would help. – Das Nuk Mar 5 '18 at 23:29