Talk serial towards A-Star

I have made a small application for scorekeeping and want to make settings through a serial connection.

e.g.
send: setup
a-star responds: set ID
send: 3
a-star conforms: set 3 and writes that to eeprom memory

Next time it starts up it shows: ‘ID’ 3

My question is how can I receive ‘setup’ and use that in an if statement, the rest of the functions work.

Hello.

You might try using readStringUntil() from Arduino’s Serial library to read incoming characters from the serial buffer into a string, until the specified terminating character is read (e.g. ‘\n’). For more information, you can see the documentation for that function on its page on the Arduino website.

- Amanda

From what I understand is that it tries to read until a timeout, that introduces waiting time.

In my application i am waiting for some user input OR serial input. So I am scanning the buttons of a 4x4 keypad in a continous loop. I want to add scanning if a specific message has been deleivered.

So I need something like:

loop
if button 1 is pressed, result = resutl + 1
if button 7 is pressed, result = result + 7
if message == “pincode”
{
do something
}

So the message needs to be received in a buffer and the loop only checks if it is there

I noticed my link was not correct and fixed it. (The original link was pointing to readString() documentation, not readStringUntil().)

You can use Serial.available() to check if there is data to be read. That function’s documentation can be found here. Since it sounds like you are not very familiar with Arduino’s Serial library, I suggest that you look at all its functions and some of its examples before continuing.

- Amanda