Help for Serial communication

So I was wondering If anyone would be kind enough to give me some sample code or an outline on how to do this:
If I want to put in say two bytes (e.g.) cu, into the serial monitor and have it process both, giving me a different outcome than putting in c or u, how would I go about doing that?

My approach was to try and put the bytes into an array and then compare that array against another (containing cu) in an if statement... I am sure that sounds stupid,236162.0.html

The read several characters function was helpful but I didn't see a way to edit it to make it perform my goal, but I am sure it is possible.

Remember that the processor works a lot faster than serial data. If it receives a “c” then it still has thousands of cycles of processing available before the “u” can arrive, even if they were transmitted as a string with no delay between. What should it do when it recognises a “cu”? How is that different if it only saw a “c” and the “u” never arrived?

The best way to think about this sort of thing is to use a “State machine.” This is a machine that remembers what state it’s in - what it has seen before - and the responses of each state are different. From your short description, I think that you need only two states:

  1. Waiting (listening to incoming serial data)
  2. Received a “c”, now waiting for a “u”.

Draw these two states on a piece of paper. Draw circles around them. Now draw arrows between the states (called “state transitions”) as follows:

In state 1, any character except “c” or “u” loops back to state 1. You keep waiting for the characters you want.

If state 1 sees a “u” then perform the action required by “u” by itself and then go back to state 1.

If state 1 sees a “c” then you go into state 2.

If state 2 sees any character except “u” then it performs the action required by “c” by itself and it goes back to state 1.

If state 2 sees a “u” then it performs the “cu” action and then returns to state 1.

If your rules are more complex - for example you only want to wait 100miliseconds in state 2 after seeing a “c” then you can draw another arrow on the page showing that case.

What do you mean by "send"? If I send 'c', how is it terminated...or is it? Same for 'u' and "cu". If by "send" you mean each is sent via clicking the Send button on the Serial monitor, that's pretty easy. If that's not the case, how are the letters being sent?

Look at the demos here and here.