[Arduino] Simple hobby motor and transistor circuit not working

Thread Starter

HunterDX77M

Joined Sep 28, 2011
104
So I'm trying to construct this simple motor circuit, where the motor spins and doesn't spin in an alternating pattern. The circuit diagram is attached and the sketch is below.

Code:
int motorPin = 9;
void setup() {
  // Pin 9 is an output pin
  pinMode(motorPin, OUTPUT);

}

void loop() {
  digitalWrite(motorPin, HIGH);
  delay(1000);
  digitalWrite(motorPin, LOW);
  delay(1000);
}
So obviously the problem is that the circuit isn't working as intended. I took a multimeter and began probing around. I found that:
  • The VDD line is about 5V, but alternates between ~4.7V and 5.0V every second (a little weird).
  • The voltage at Pin 9 alternates between 0 and 5V (that's correct).
  • The voltage across the motor alternates between 0V and 0.07 volts every second (totally wrong).
The diode I am using is 1N4003. When I tested it out in my multimeter, the forward voltage was 600 to 700 mV, which sounds correct. I'm thinking my transistor might be wrong or not functioning. The diagram calls for what looks like an NPN, so I am using a 2N4124, which is an NPN according to the datasheet. The hFE I measured falls within the minimum/maximum listed. I'm using a 2K resistor instead of a 2.2K, as shown in the diagram.

The motor itself is working. I attached both ends to a plain AA battery briefly and it spun.

At this point, I'm not sure what else could be wrong in the circuit. Any tips on where else I should focus my debugging efforts?
 

Attachments

shteii01

Joined Feb 19, 2010
4,644
Hey, shteii01. Thanks for replying.

According to this page, the absolute max per pin is 40 mA. How much do you think a hobby motor would need?

http://playground.arduino.cc/Main/ArduinoPinCurrentLimitations
I don't know. Do you know what hobby motor is? Who made it? What voltage it uses? What current it uses?

I can tell you that dc motor fans in pc need 100 to 140 mA. If I send 40 mA to one of them, they will simply laugh and point finger at me.

Have you tried this tutorial:
 

John P

Joined Oct 14, 2008
2,025
Try shorting C and E of the transistor, so the motor is running directly off 5V. If it runs, the problem is that the transistor isn't working or isn't being turned on. If it doesn't run, the power supply isn't adequate to make it work.
 

dannyf

Joined Sep 13, 2015
2,197
I'm not sure what else could be wrong in the circuit.
Too many - as you have given very little information about your set-up.

An obvious question would be what kind of motor and how much current it draws and what kind of voltage source it needs to drive it. I would re-route the motor to the power source directly but knowing what you are dealing with first would be key in finding out the source of your troubles.
 

ScottWang

Joined Aug 23, 2012
7,397
As a hobby motor and assuming it's current as this needs 110 mA,
When you using the bjt as switch then the hFE will be count it as 10.
Ib = 110 mA/hFE
= 110 mA/10
= 11 mA.

You could prepare a little more current for Ib as 15 mA.
Rb = (V_d9 - Vbe)/Ib
= (5V - 0.7V)/15 mA
= 286.7Ω

You could using 270Ω for Ib = 16 mA or 300Ω for Ib = 14.3 mA.
 

shteii01

Joined Feb 19, 2010
4,644
As a hobby motor and assuming it's current as this needs 110 mA,
When you using the bjt as switch then the hFE will be count it as 10.
Ib = 110 mA/hFE
= 110 mA/10
= 11 mA.

You could prepare a little more current for Ib as 15 mA.
Rb = (V_d9 - Vbe)/Ib
= (5V - 0.7V)/15 mA
= 286.7Ω

You could using 270Ω for Ib = 16 mA or 300Ω for Ib = 14.3 mA.
i don't think they can source 110 mA from Arduino board.
 

shteii01

Joined Feb 19, 2010
4,644
Please read my posted again.
You made an assumption that motor needs 110 mA.
Based on this assumption you calculated Ib of 11 mA, you then modified this Ib to 15 mA, which is fine because Uno can normally source 20 mA from its pins.
Using Ib of 15 mA you calculated base resistor Rb to be 286 Ohm, then you gave OP the choice of using standard 270 Ohm or standard 300 Ohm base resistors, which is also fine.

But here is the thing. All this calculations are based on that initial assumption that Ic will be 110 mA. The way OP wired his motor, the Ic will come from Uno and Uno CAN NOT produce 110 mA. So, yes, the Uno will send 15 mA into the base, it will turn motor on, the motor will try to draw 110 mA from the Uno, Uno will peak at about 40 mA and that is it, it can not supply any more current to the motor.
 

ScottWang

Joined Aug 23, 2012
7,397
You made an assumption that motor needs 110 mA.
Based on this assumption you calculated Ib of 11 mA, you then modified this Ib to 15 mA, which is fine because Uno can normally source 20 mA from its pins.
Using Ib of 15 mA you calculated base resistor Rb to be 286 Ohm, then you gave OP the choice of using standard 270 Ohm or standard 300 Ohm base resistors, which is also fine.

But here is the thing. All this calculations are based on that initial assumption that Ic will be 110 mA. The way OP wired his motor, the Ic will come from Uno and Uno CAN NOT produce 110 mA. So, yes, the Uno will send 15 mA into the base, it will turn motor on, the motor will try to draw 110 mA from the Uno, Uno will peak at about 40 mA and that is it, it can not supply any more current to the motor.
Max current out of 5v pin on UNO?
 
Top