I am using an Arduino to control servo MX18A by serial, and trying to use computer to communicate with the Arduino by another serial to send commands to Arduino and change the servo control mode. Once the computer send a message to Aruduino, I hope it could response in time because may be there is something emergency like the servo being out of control ,under which circumstance I have to change the control strategy in time.
However, it seems like Arduinos like UNO, MEGA does not have serial interruption, so once the message from computer comes, it could not response in time.
I know that judging
serial.available() in every loop is one solution, but in my different servo control strategy there are many time delays,
for loops and
while loops, which means that I have to put
serial.available() in every time delay or
for loops, making the code hard to write and maintain.