Overview
In this project, we will make DC Motor/Fan Speed Controller using Raspberry Pi Pico with MicroPython Code. We will use Motor Driver Module, DC Motor, and a potentiometer for this application.
Whenever we rotate the potentiometer, the motor driver is controlled with different output voltages. this output voltage is used to drive the DC Motor as its speed increases or decreases depending on the PWM signal. Finally, the effect of speed regulation fan is achieved.
Components Required
In this guide, I used Elecrow Raspberry Pi Pico Starter Kit to test different Modules. You can buy the kit and perform some other operations as well. From this kit, you can use the following components.
1. Raspberry Pi Pico Board – 1
2. Potentiometer Module – 1
3. L9110S Motor Drive Module – 1
4. DC Motor – 1
5. Fan Blade – 1
6. Breadboard – 1
7. Jumper Wires – 4
8. Micro-USB Cable – 1
L9110S Motor Drive Module
The motor drive module is mainly controlled by the L9110S chip. The L9110S is a two-channel push-pull power amplifier ASIC designed for controlling and driving motors. The two output ends of the drive module can directly drive the forward and reverse motion of the motor. It has a large current drive capability.
Each channel can pass a continuous current of 800mA, and the peak current capability can reach 1.5A. L9110S is widely used in toy car motor drives, pulse solenoid valve drives, stepper motor drives and switching power tubes, and other circuits.
Circuit Diagram & Connection
The connection diagram for the Motor/Fan Speed Controller with Raspberry Pi Pico is given below.
Connect the GND, VCC, A-1A, and A-1B terminal of the motor driver module to the GND, 3V3, GP15, and GND of the Raspberry Pi Pico Board respectively. Connect the 5V DC Motor to Motor Driver Module A terminal.
Connect the VCC, GND & Analog Output Pin of the Potentiometer Module to the 3V3, GND & GP26 Pin of the Raspberry Pi Pico Board.
MicroPython Code/Program
Open your Thonny IDE & Copy the following code & paste it to the editor window.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
from machine import Pin,ADC,PWM from time import sleep A_1A_pin = 15 # Motor drive module Pot_pin = 0 # ADC0 multiplexing pin is GP26 def setup(): global A_1A global pot_ADC A_1A = PWM(Pin(A_1A_pin)) A_1A.freq(1000) #Set the driver operating frequency to 1K pot_ADC = ADC(Pot_pin) def loop(): while True: print ('Potentiometer Value:', pot_ADC.read_u16()) Value = pot_ADC.read_u16() A_1A.duty_u16(Value) # control fan speed sleep(0.2) if __name__ == '__main__': setup() loop() |
Now you can run this code to test the working of the circuit.
Rotate the potentiometer to control the motor driver to output different voltages to achieve the effect of a speed regulation fan.











1 Comment
Is it not a bad idea to power the motor and controller from the low current 3.3v supply? Could the motor and controller be powered from 5v and would the pico 3.3v logic signal be compatible with the controller inputs?