i have a little project going on, where i want to connect vibration motors to an arduino. I found this, with example code but also found other tutorials wish use a capacitor for the motor. What is the advantage of using one ?

I am currently planning to power the arduino by a 9V battery, with 3 ultrasound sensors being connected to the 5v output of the arduino. Hence, i believe that i need an external battery for the 2 vibration motors. I think 2x AA's should do the job for some hours, right ?

I also have a question about the rating of the resistor to use at the base of the transistor. How do i calculate the rating that i need ?

closed as off-topic by VE7JRO, sempaiscuba, MatsK, per1234, Greenonline Sep 27 '18 at 16:44

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question does not appear to be about Arduino, within the scope defined in the help center." – VE7JRO, sempaiscuba, MatsK, per1234, Greenonline
If this question can be reworded to fit the rules in the help center, please edit the question.


a transistor is a current controlled current source. it means that you can control how much current is "Allowed" to flow from emitter to collector, by controlling the minor current flowing through the base of transistor. there is a specific ratio for this two currents for various transistors. (I recommend reading some transistor tutorials). let's say, your motor is drawing 250mA in full speed. you want to "allow" up to 300mA to be available to it.

  1. base is connected to 5V through a 2.2 kOhm resistor. The base current is : (5/220) ~= 2.2mA
  2. the hfe of your transistor is 150 (it depends on transistor model. It’s written in the datasheet available for every transistor on the market. it's the ratio of base current and emitter collector current mentioned above. You “must” read it first as it’s highly various between transistor models).
  3. The current allowed to flow from emitter to collector is 2.2mA * 150 = 330mA which is sufficient for you motor.

note : many simplifications are made to make it easier to understand.


Resistor is there to limit Arduino current out. 220, 270, 330, any should be okay.

Be sure to connect battery - to Arduino Gnd. Transistor will be used to connect motor '-' to Gnd? Be sure to put a diode across it - anode to motor '+', cathode to motor '-' to dissipate current surge generated by the motor when the transistor turns off.

2AAs will last a little while. Better than using 9V for them, that will drain a battery quick.

Not the answer you're looking for? Browse other questions tagged or ask your own question.