control 12v motor with NPN transistor via arduino

• i want to control this 12v motor via arduino:

Power source is 12v 5A

motor will work 5 seconds in every 5 minutes and will be activated throught arduino mega

i will try to use bd679a darlington transistor:

• Collector - Base Voltage (Vcbo) 80 V
• Collector - Emitter Voltage (Vceo) 80 V
• Collector Current (Ic) 4 A
• Power Dissipation (Pd) [Tcase≤25°C] 40 W
• Transition Frequency (fТ) 10 MHz
• Min. DC current gain (β) 750
• Integrated diode Yes Case TO-126 Package type -14h

Do i need to add diode(and will that drop voltage ) ?

also do i need any ressistors and why?

• what research have you done? ... there are many tutorials about DC motor control on the web Commented Dec 11, 2022 at 17:47
• someone tell they use 12k on DC- and arduino but no one tell why and how much W resistor should be Commented Dec 11, 2022 at 17:53
• also they use 330k resistor from arduino pin to transistor and when i go to buy it ask me to chose 1/4W 1/2W 1W ... which one should i chose Commented Dec 11, 2022 at 17:55
• any of those would work Commented Dec 11, 2022 at 18:08
• here is one of the tutorials ... docs.arduino.cc/learn/electronics/transistor-motor-control Commented Dec 11, 2022 at 18:45

You are missing 2 things:

• You should add a resistor between the Arduino digital IO pin and the base of the transistor. Bipolar transistors are current amplifiers. Normally for driving motors with a microcontroller you want the transistor to operate in saturation anyway, so there is no need to fine tune the resistor. It is there for protecting the output pin of the Arduino from over current. The calculation is easy: Resistance is voltage divided by current `R = U / I`. The voltage is 5V for an Arduino Mega (output voltage of the digital IO pins is equal to the operating voltage of the Mega, thus 5V). The current here is the max current, that the output pin can withstand (you find such information in the datasheet of the microcontroller). It is 20mA for continuous load.

So `R = 5V / 20mA = 250 Ohm`. Thus you need a resistor with at least 250 Ohm. 330 Ohm is normally readily available, so often people use one of these.

You also asked about how many wants it should withstand. This is also easy to calculate: Power (in Watts) is voltage multiplied by current. So `P = U * I = 5V * 20mA = 0.1W`. So in this configuration the resistor will not ever need to withstand more than 0.1W. So 1/4W is enough.

• When driving motors you should include a flyback diode. This is a diode in reverse direction connected across the terminals of the motor. A motor is an inductive load (since it basically consists of some coils and magnets). Driving it with a varying voltage (like you need for controlling the motors speed or just to start and stop the motor) will induce reverse voltage spikes. These might damage your transistor and/or the Arduino. With the flyback diode connnected these voltage spikes can safely dissipate through that diode and not causing any harm.

So the circuit looks like this:

simulate this circuit – Schematic created using CircuitLab

• This is an emitter follower circuit, you will only get the base voltage ~ -0.70 volts depending on the gain, it will not switch. You need to either go to a low side switch or a PNP transistor and the emitter would go to +12. A P-Channel MOSFET would also work. Check your calculations on the 1N4148, under stall condition I believe it will fail.
– Gil
Commented Dec 13, 2022 at 1:00
• im using bd679a darlington transistor , can it damage the arduino if i dont add 330ohm resistor . is that a MUST or optional? Commented Dec 15, 2022 at 21:08
• @wuqnyqow: The base resistor is not optional. Commented Dec 16, 2022 at 9:23