Remote controlled robot with smooth start / stop

Hi, I have designed robot that can be remotely controlled. However, to avoid the jerk at the time of starting and stopping, I have programmed the robot to start slowly and gain speed and slow down everytime I press the Move forward button in my program. But this poses a challenge, if I want the robot to run continuously by pressing the forward button multiple times, the robot starts slowly gains speed stops and then again does the same for every key stoke. How can I make my robot run at full speed, if it received next move forward button while it is going at full speed instead of slowing down and ramping again.

I can send data only to serial interface remotely and there is no pin signal I can manipulate when the key is pressed.

Is it possible to trigger, interrupt routine to read the serial interface whenever the serial input receives any input and continue the motor speed or do as commanded by the serial data? My robot has lot of space to cover and large number of obstracles to over-come. So if it detects free space, it should run faster and if any obstruction is seen, it should slow / stop and turn right / left based on inputs received serially.

My robot is basically a line sensing robot that has to run on uneven surface and very easily, it can go outside the sensing circuit / line.

Thanks,

Is it possible to trigger, interrupt routine to read the serial interface whenever the serial input receives any input

The serial interface already triggers an interrupt whenever something arrives.

What's the real problem?

The sending end should send a value when the switch BECOMES pressed, and another when it BECOMES released.

Then, the robot only gets ONE start command and ONE stop command, and your "problem" goes away.

Thanks PaulS/AWOL,

The robot receives “5” for going forward, “4” for left and “0” for emergency stop via the serial interface.

Once when “5” is received on serial interface by the arduino, it drives the motor in forward direction for 6 seconds (the speed starts from 0 to max speed and then slows down to 0). If the arduino receives “5” again, it will do the same again. This makes the movement jerky. When I send “0” for emergency stop it takes effect only after the commands on the serial buffers are executed by which time, my robot dashes against the object.

Let us say, if the robot is running at 50% speed and the arduino receives “5” again, I want the speed to increase to 100% speed from 50% instead of slowing down / stopping and starting again. (“0” received would stop the motor gracefully from 50% to 0% speed gracefully in a similar way)

If I program the robot to run forward until any key is pressed, the line tracking is not happening properly. I saw some posts mentioning that the “print” statements (that I have inserted for knowing the sensor values) can be the cause for this. I need to verify this aspect and I shall come back.

Thanks again!