Sending AT commands via switch case in Arduino
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
1
down vote
favorite
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)
input = Serial.read();
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";
beginner c arduino serial-port
add a comment |Â
up vote
1
down vote
favorite
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)
input = Serial.read();
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";
beginner c arduino serial-port
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 at 22:12
I can post my full code if that would help.
â Das Nuk
Mar 5 at 23:29
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
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)
input = Serial.read();
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";
beginner c arduino serial-port
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)
input = Serial.read();
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";
beginner c arduino serial-port
edited Mar 2 at 1:56
200_success
123k14142399
123k14142399
asked Mar 2 at 0:38
Das Nuk
235
235
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 at 22:12
I can post my full code if that would help.
â Das Nuk
Mar 5 at 23:29
add a comment |Â
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 at 22:12
I can post my full code if that would help.
â Das Nuk
Mar 5 at 23:29
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 at 22:12
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 at 22:12
I can post my full code if that would help.
â Das Nuk
Mar 5 at 23:29
I can post my full code if that would help.
â Das Nuk
Mar 5 at 23:29
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f188647%2fsending-at-commands-via-switch-case-in-arduino%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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 at 22:12
I can post my full code if that would help.
â Das Nuk
Mar 5 at 23:29