Serial text command to pan tilt servos

My sketch does not wait 5 ms and exit readSerialString. readSerialString is only called when I press enter through the Serial Monitor. Perhaps that's not what it should do, but that's what I experience. If you look at my sketch you can see there is no trapping for exit characters and yet the functions work, theory be damned.

As an aside, I believe this is undocumented on Arduino. Serial.available is set false when it gets a LF and/or CR

I understand how you might think I'm dense. When I don't have the servos attached I don't need the 5 ms delay.

But with the servos attached if I don't have a 5 ms delay the sketch behaves more like you think it should behave. That is, it seems to write P to the buffer right away and calls the processServo function.

However, the trapping for exit characters does NOT fix that. I tried your code and others. All with the same result.

I believe if you attach 2 servos and run my sketch you will have a lot to think about too :wink:

I don't mean to be disrespectful. I really appreciate your help!! But a few people have been working on this and I'm not the only one thinking about it. We still remain at the same place. No one has sent me code, or a sketch, that works without the 5 ms delay.

I wouldn't be surprised if it's something silly I'm missing. Again, I just don't have the code to prove it.