Start Up a DC-Motor veeery slowly

Hey everybody,

i own a RC-Car with a DC-Motor and a complete Arduino-based control. Every time I send a command to drive (no matter which direction), the motor runs with this PWM (in my case 100) instantly. It doesn´t sounds very good :astonished:

Is there a chance to start it up a little bit softer (e.g. within 1second)? Is there a command or something for that?

Code snipped:

Serial.available();
value = Serial.read;
...
if (value='w') {
digitalWrite(In1A, LOW);
digitalWrite(In1B, HIGH);
analogWrite(PWM, 100);
}

greetings K86

if (value='w') {
  digitalWrite(In1A, LOW);
  digitalWrite(In1B, HIGH);
  for (int i = 1; i < 100; ++i) {
    // increase PWM by 1 unit every 10ms, so we get 100 after 1 second
    analogWrite(PWM, i);
    delay(10);
  }
}

The Arduino won’t be able to respond to new received characters during this 1 sec period. You can get round that, but it’s more complicated.