
Driving a Motor — SIK Circuit 12
Ìlànà
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
Àwọn ohun èlò fún ìgbésẹ̀ yìí:
SparkFun Inventor's Kit - V3.21 ohun èlòÀwọn irinṣẹ́ tí a nílò:
Kọ̀ǹpútà Tí Ó Ní Arduino IDEHardware 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.
Àwọn ohun èlò fún ìgbésẹ̀ yìí:
Ẹ̀rọ DC oníhàmọ́1 ẹyọ
Okùn Ìsopọ̀6 ẹyọÀwọn irinṣẹ́ tí a nílò:
Pátákó ÀdánwòArduino Code
Arduino Code
Open the Arduino IDE and upload the following sketch to your Arduino board.
Àwọn ohun èlò fún ìgbésẹ̀ yìí:
Arduino Uno R31 ẹyọÀwọn irinṣẹ́ tí a nílò:
Kọ̀ǹpútà Tí Ó Ní Arduino IDETest & 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.
Àwọn ohun-èlò
7- 1 ohun èlò$108.26
- Àyè
- Àyè
- Àyè
- 1 ẹyọÀyè
- 1 ẹyọÀyè
- 1 ẹyọÀyè
Àwọn irinṣẹ́ tó nílò
2- 1 vendor sell this, none ship to you yetÀyè
CC0 Àgbègbè Gbogbogbò
Blueprint yìí ti jáde lábẹ́ CC0. O lè ṣe àdàkọ, yí padà, pín, àti lò láìsí ìyọ̀ǹda.
Ṣàtìlẹ́yìn Olùṣẹ́dá nípa rírà àwọn ọjà nipasẹ̀ Blueprint wọn Ẹ̀san Olùṣẹ́dá tí àwọn Olùtajà gbé kalẹ̀, tàbí ṣẹ̀dá àtúnṣe tuntun ti Blueprint yìí kí o sì fi sínú Blueprint rẹ gẹ́gẹ́ bí ìsopọ̀ láti pín owó-wíwọlé.