Soft start on ENA
Arduino C++Pull the ENA cap and wire ENA to D9. Drive motor A forward (IN1 on D8 HIGH, IN2 on D7 LOW) and ramp ENA from 0 to 255, one step every 10 ms, so it reaches full speed in about 2.5 s. Hold full speed for 2 s, then brake by taking IN2 HIGH and print "stopped".
Checks
- Not run yetRuns for 5.5 s
- Not run yetIN1 (D8) is HIGH
- Not run yetIN2 (D7) is LOW while driving
- Not run yetAt 0.25 s ENA (D9) is at about 10%
- Not run yetAt 1 s ENA is at about 40%
- Not run yetAt 3.5 s ENA is at full duty
- Not run yetAt 5 s IN2 is HIGH: braking
- Not run yetPrints "stopped"
Hints
- Set the direction once, before the ramp: digitalWrite(IN1, HIGH); digitalWrite(IN2, LOW);
- A for loop from 0 to 255 with analogWrite(ENA, duty) and delay(10) inside gives the ramp.
- Brake is IN1 = IN2 with the bridge enabled: IN1 is already HIGH, so set IN2 HIGH too.