
Driving a Motor — SIK Circuit 12
Maagizo
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
Vifaa kwa hatua hii:
SparkFun Inventors Kit - V3.21 kifaa
Arduino Uno R31 kipande
Breadboard1 kipande
DC Motor1 kipande
NPN Transistor (P2N2222A)1 kipande
Diode (1N4148)1 kipande
330 Ohm Resistor1 kipande
Jumper Wires6 vipandeZana zinazohitajika:
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.
Vifaa kwa hatua hii:
DC Motor1 kipande
NPN Transistor (P2N2222A)1 kipande
Diode (1N4148)1 kipande
330 Ohm Resistor1 kipande
Breadboard1 kipande
Jumper Wires6 vipandeArduino Code
Arduino Code
Open the Arduino IDE and upload the following sketch to your Arduino board.
Vifaa kwa hatua hii:
Arduino Uno R31 kipandeZana zinazohitajika:
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.
Vifaa
8- $105.00
- 1 kipandeKishikilia Nafasi
- 1 kipandeKishikilia Nafasi
- 1 kipandeKishikilia Nafasi
- 1 kipande$3.00
- $5.00
You can swap these in
Can't get one of the materials? Swap it for an equivalent — these work just as well.
- Instead of Arduino Uno R3, try:
Prototyping Shield for Arduino Uno (3-Pack)
Arduino Uno R3 Board
Arduino Uno - Instead of DC Motor, try:
Vibration Motor Assortment
Servo Motor
SG90 Micro Servo Motor (5-Pack)
Marine Brushless Motor
Vibration Motor - Instead of Diode Kit, try:
Bridge Rectifier Diode Kit (20pcs)
1N5819 Schottky Diode (20-Pack)
Zener Diode - 5.1V 1W - Instead of Resistor 330 Ohm 1/6 Watt PTH - 20 pack, try:
Resistor 10K Ohm 1/6th Watt PTH - 20 pack
Recommended for this build
Products makers often use with builds like this one.
5mm LED Assortment Kit (300pcs, 5 Colors)Used together and in similar builds
Servo MotorUsed together and in similar builds
Relay ModuleUsed in similar builds
Temperature SensorUsed in similar builds
Flex Sensor 2.2 InchUsed together and in similar builds
Resistor 10K Ohm 1/6th Watt PTH - 20 packUsed together and in similar builds
LED - RGB Diffused Common Cathode - 5mmFrequently used with this build's materials
Push Button - 33mmFrequently used with this build's materialsRelated blueprints
Other builds that share materials, tools, or techniques with this one.






CC0 Umma Wote
Mchoro huu umetolewa chini ya CC0. Uko huru kunakili, kubadilisha, kusambaza, na kutumia kazi hii kwa madhumuni yoyote, bila kuomba ruhusa.
Saidia Mtengenezaji kwa kununua bidhaa kupitia Mchoro wao ambapo wanapata Kamisheni ya Mtengenezaji iliyowekwa na Wachuuzi, au unda marudio mapya ya Mchoro huu na uiunganishe kama kiungo katika Mchoro wako kuchangia mapato.