How to print specific values ( etc. 0-255 values) from a random input.

The video I uploaded shows how the program should work. I want to join a project group in my university so I'm learning Arudino and communication protocols. This program must communicate with UART ( Serial )

So if input's first bit is 'S', continues with '0' or '1', continues with an integer between 0-255, continues with '0' or '1' continues with an integer between 0-255, and finally finishes 'F', it prints the values. If there is useless, random letters and numbers, program eliminates them find the needed information.

This video shows how it should work.- YouTube

I don't even know how to approach such a problem like this. I know arrays and stuffs but I desperately need your helps guys.

Do you know how to read characters from Serial and test their value ?

Can you not just read characters and ignore irrelevant values ?

UKHeliBob:
Do you know how to read characters from Serial and test their value ?

Can you not just read characters and ignore irrelevant values ?

I know most of the serial functions and I know how to read characters. I don't know how to test their values, though. And I don't know how to ignore some values as well.

UKHeliBob:
Do you know how to read characters from Serial and test their value ?

Can you not just read characters and ignore irrelevant values ?

But I can understand what's going on if I take a look at codes.

I don't have much time to help but start simple

void setup()
{
  Serial.begin(115200);
}

void loop()
{
  if (Serial.available())
  {
    char inChar = Serial.read();
    if (inChar == 'A')
    {
      Serial.println("Got an A");
    }
    else if (inChar == '9')
    {
      Serial.println("Got a 9");
    }
    else if (inChar == 'x' || inChar == 'X')
    {
      Serial.println("Got an x or an X");
    }
    else
    {
      Serial.print("Ignoring ");
      Serial.println(inChar);
    }
  }
}

Can you give some examples of what the received strings will be? Particularly when there is useless random letters mixed in - where do those come from?

wildbill:
Can you give some examples of what the received strings will be? Particularly when there is useless random letters mixed in - where do those come from?

Actually the video I uploaded shows program should work. Program only prints if inputs are in desired order and that order is 'S' - '0' or '1' (it shows which way is motor running, forward or reverse) - number between '000' and '255'(it's motor's speed) - '0' or '1' (other motor's direction) - number between '000' and '255' and 'F'. English is not my mother language so I understand that I can't explain exactly how it works but I'm doing my best.

So it looks as though you're simply concerned about user error on input. Given that you're pressed for time, I'd suggest that you start out with writing something that deals with well formed input and then add some defense against bad data.

Which would basically be:
Read and throw away characters until you see an S
Read and store characters until you see an F
Chop out the fields you want and print them.

The first (vital) defense against bad data would be to ensure that the data you're reading isn't longer than the array you defined to put it in.

You may find Robin2's serial tutorial helpful.

A second thing that would eliminate most of your bad data would simply be to only store digits when you've seen an 'S' and are looking for an 'F'.

What will you do if there is a second 'S'?

wildbill:
A second thing that would eliminate most of your bad data would simply be to only store digits when you've seen an 'S' and are looking for an 'F'.

What will you do if there is a second 'S'?

We look for the last 'S'?

We look for the last 'S'?

How do you know that it is the last 'S' until you have read the final 'F' ?

UKHeliBob:
How do you know that it is the last 'S' until you have read the final 'F' ?

I honestly don't have any idea. We might search for 8 amount of numbers(for 0-1, 255, 0-1, 255, it adds up to 8 numbers) between 'S's and 'F's?

anthonyHope:
You may find Robin2's serial tutorial helpful.

I checked it out but my problem seems like much more complex than examples in that tutorial. I don't even know how to approach to this problem or where to start.

Start with code that works for the simple case only as I suggested in reply #7. Once you have that you can tweak it to deal with error cases.

Are your users going to deliberately try to break your system or are you just worried about typos?

wildbill:
Start with code that works for the simple case only as I suggested in reply #7. Once you have that you can tweak it to deal with error cases.

Are your users going to deliberately try to break your system or are you just worried about typos?

They are going to deliberately try to break it. They would give inputs in every possible ways.

frequiem11:
They are going to deliberately try to break it. They would give inputs in every possible ways.

Ok. Doesn't change the strategy though: get the simplest possible thing working and then improve it.

It's probably worth creating a file with test cases in it too, so you can check each new iteration of your code against them.