Recommended · for beginners
Controlling a DC Motor with the Raspberry Pi
Why people recommend it
A beginner tutorial on driving a small DC motor from Raspberry Pi GPIO with a transistor and PWM, suggested as a basics starting point.
Watch for: Check the PWM frequency used suits your motor
In their words
More specifically, I want to control its speed using pulse width modulation (PWM) as is explained in this video Controlling a DC Motor with the Raspberry Pi.
MuadDev on raspberrypi.stackexchange.com, Jan 2018. CC BY-SA.
The motor is something like that but without transistor.
kahonmlg on raspberrypi.stackexchange.com, Oct 2014. CC BY-SA.