1. adopt professional DC motor drive chip. For example: L298N
2. This is realized by bridge circuit design. Four transistors or MOS transistors are connected to a bridge circuit, and the positive-negative conversion is completed by controlling these four transistors. Pay attention to leave a certain dead time when two pairs of transistors are turned on, otherwise the positive and negative electrodes will be short-circuited.
The above two methods plus PWM can also complete the speed regulation function, haha, very simple.