艺术
美容与健康
工艺
文化与历史
娱乐
环境
食品与饮料
逆向工程
科学
体育
技术
可穿戴设备

Driving a Motor — SIK Circuit 12
Spin a DC motor at variable speeds using a transistor as a switch. Learn about transistors, flyback diodes, PWM motor control, and serial input for speed control.
说明
1
1
Parts & Introduction
Parts & Introduction
DC motors draw too much current for an Arduino pin to drive directly. A transistor acts as an electronic switch — a small signal from the Arduino controls a larger current flowing through the motor. The flyback diode protects against voltage spikes when the motor turns off.
Parts Needed
- 1x Arduino Uno + USB cable
- 1x Breadboard
- 1x DC Motor
- 1x NPN Transistor (P2N2222A)
- 1x Diode (1N4148)
- 1x 330Ω Resistor
- 6x Jumper Wires
此步骤所需材料:
SparkFun Inventors Kit - V3.21 套件Arduino Uno R31 个
Breadboard1 个
DC Motor1 个
NPN Transistor (P2N2222A)1 个
Diode (1N4148)1 个
330 Ohm Resistor1 个
Jumper Wires6 个所需工具:
Computer with Arduino IDE
2
2
Hardware Hookup
Hardware Hookup
Wiring Instructions
Transistor pinout (flat side facing you, pins down): Collector, Base, Emitter (left to right).
- Place the transistor in the breadboard.
- Connect Base (middle pin) through a 330Ω resistor to Arduino Digital Pin 9.
- Connect Emitter (right pin) to GND.
- Connect Collector (left pin) to the motor's black wire.
- Connect the motor's red wire to 5V.
- Flyback Diode: Connect the banded end (cathode) to 5V, the other end (anode) to the motor's black wire.
此步骤所需材料:
DC Motor1 个
NPN Transistor (P2N2222A)1 个
Diode (1N4148)1 个
330 Ohm Resistor1 个Breadboard1 个
Jumper Wires6 个3
3
Arduino Code
Arduino Code
Open the Arduino IDE and upload the following sketch to your Arduino board.
dc_motor.inoarduino
此步骤所需材料:
Arduino Uno R31 个
所需工具:
Computer with Arduino IDE
4
4
Test & Experiment
Test & Experiment
What You Should See
The default serialSpeed() function lets you type speed values (0-255) into the Serial Monitor to control motor speed in real time.
Troubleshooting
- Motor not spinning: If you sourced your own transistor, double-check the pinout — many NPN transistors have reversed pin orders compared to the P2N2222A.
- Motor won't start at low values: Below ~50, the motor doesn't have enough torque to overcome friction. This is normal.
- Connection issues: Try unplugging and re-plugging the USB cable.
Experiments to Try
- Uncomment
motorAcceleration()to see smooth speed ramping. - Add a potentiometer to control speed with a knob instead of serial input.
- Add a button for on/off control.
材料
8- $105.00
估计总额
$138.00CC0 公共领域
此蓝图以 CC0 协议发布。你可以自由复制、修改、分发和使用此作品,无需征得许可。
通过购买蓝图中的产品支持创客,他们将获得 创客佣金 (由供应商设定),或创建此蓝图的新版本并将其作为连接包含在你自己的蓝图中以分享收入。