Five speeds, both ways
Arduino C++Drive motor A forward at five PWM steps (51, 102, 153, 204, 255), one second each, brake for half a second, then do the same in reverse and brake again. Keep STBY HIGH the whole time.
Checks
- Not run yetRuns for the whole 11 s
- Not run yetSTBY (D9) is HIGH
- Not run yetForward: AIN1 (D7) is HIGH
- Not run yetForward: AIN2 (D8) is LOW
- Not run yetFirst step: PWMA at 20%
- Not run yetThird step: PWMA at 60%
- Not run yetFifth step: PWMA at 100%
- Not run yetReverse: AIN1 (D7) is LOW
- Not run yetReverse: AIN2 (D8) is HIGH
- Not run yetReverse, first step: PWMA at 20%
- Not run yetReverse, fifth step: PWMA at 100%
Hints
- Direction is AIN1 and AIN2, speed is analogWrite(PWMA, …): set the direction once, then step the PWM.
- 51 × i for i = 1 to 5 gives the five steps; delay(1000) after each one.
- Brake is AIN1 = AIN2 = HIGH. Write both pins every time; never rely on the pull-down.