Hi All,
I'm trying to make a program that it reads from serial and replies.
If I use Ardiuno IDE > Tools > Serial Monitor it reads line and replies to the commands.
But if I use Tera Term it only reads one character at a time.
Here's my code:
#define CMDBUFFER_SIZE 32
String readString;
void setup()
{
Serial.println("Ardiuno Started");
Serial.begin(115200);
Serial.setTimeout(3);
}
void loop()
{
while(Serial.available())
{
delay(3);
readString = Serial.readStringUntil('\n');
if(readString.length()>0)
{
Serial.print("First String is ");
Serial.println(readString);
if(readString == "AT" || readString == "at")
{
Serial.println("OK");
}
else if (readString == "AT+RESET" || readString == "at+reset")
{
Serial.println("Resetting the device");
}
else if(readString == "AT+RANDOM" || readString == "at+random")
{
for (int i = 0; i < 300; ++i)
{
int randInt = random(300);
Serial.println(randInt);
delay(50);
}
}
else
{
Serial.println("No Command Found");
}
readString = "";
Serial.println(readString);
}
}
}
How can I configure my code or environment to achieve communicate from Tera Term?