Driving a Motor with the Pico
The Pico has 26 general purpose input and output pins. However, each pin's power is designed to digitally communicate with other devices and has a limited current capacity of around 17 milliamps according to the Raspberry Pi Pico Datasheet Table 5. 17 milliamps is fine for lighting up an LED. However, motors require much more power. 17 milliamps is not enough current to drive even small motors. Even our small DC hobby motors we use with our robots require around 200 milliamps.
But don't worry! We have two ways around this problem.
- The first option is to use a simple transistor as a "switch" that will use our low-power digital signal to control its on-and-off settings.
- The second option is to use a full motor driver chip such as an L293D chip. This chip takes the same PWM signal we learned about in our Fade In and Out Lab.
Basic Transistor Circuit
- Transistor NPN 2222A
- Diode: 1N1448
- Motor: 3-6 volt hobby motor
PWM Control
PWM Frequency
Set the frequency to 50Hz (one cycle per 20ms) and the duty value to between 51 (51/1023 * 20ms = 1ms) and 102 (102/1023 * 20ms = 2ms)
Sample Coder
1 2 3 4 5 6 7 8 |
|