I have been atempting to create a function that will listen for serial input and then compare that input against a list of commands.
It seems to work but it keeps looping and presenting the prompt.
Am i missing some thing?
void loop()
{
String CommandToRun;
CommandToRun = getSerialInput();
if (CommandToRun == "run")
{
Serial.println("Command received\n");
}
}
String getSerialInput()
{
Serial.println("\n>");
String someInput;
while (Serial.available() > 0)
{
delay(10);
char recieved = Serial.read();
// Process message when new line character is recieved
if (recieved == '\n')
{
Serial.println(someInput);
return someInput;
}
someInput += recieved;
}
}
http://esp8266basic.com
A BASIC interpreter for your ESP
Working now on Autodrop3d. A 3d printer with automatic part ejection system. https://autodrop3d.com