The problem:
In the circuit displayed below, I have a microcontroller supplying current to the base of a NPN 2N2222 transistor. When the battery is at 9V, this setup works great: the microcontroller can supply 5mA and fully open the transistor.

When the battery drops voltage over time, however, this causes a massive change the amount of current required by the microcontroller/base to open the transistor. (see diagrams below)

My setup when the battery is at 9V enter image description here

My setup when the battery is at 8V enter image description here

What my goal is:
I want to use PWM supplied from the microcontroller to the base to control my 6V motors, which are being powered from a 9V battery, using somewhere around 2-12mA of current from the microcontroller. I have read up on base biasing, but I have not been able to reproduce the results I want on my own. I have a feeling that this will all boil down to some basic V=IR logic, but despite my best efforts I haven't been able to think of a way to do so.

Does anyone have any advice on how they would change this circuit to achieve that goal? I really appreciate your time.

  • \$\begingroup\$ What is the reason for R2? \$\endgroup\$ Mar 19, 2023 at 6:32
  • 1
    \$\begingroup\$ Use a base resistor to control base current. As depicted, you use an emitter resistor, controlling emitter = base+collector current. Use a diode to protect the transistor from back EMF. Depending on motor current, have an eye on current gain and collector-emitter voltage: multiplied by current, the dissipated power may be too much. \$\endgroup\$
    – greybeard
    Mar 19, 2023 at 8:00
  • \$\begingroup\$ To supplement @graybeard's comment: remove the 5-ohm resistor R2 and connect the transistor's emitter directly to ground. Add a resistor between the microcontroller's digital I/O (DIO) pin and the transistor's base. This resistor's value must be chosen to (a) supply enough current into the transistor's base to drive the transistor into hard saturation, and (b) limit the DIO pin's output current to a level that is well below the DIO pin's maximum output current rating. See also: electronics.stackexchange.com/a/488355/79842 \$\endgroup\$ Mar 19, 2023 at 10:14
  • 1
    \$\begingroup\$ What does this mean --> open the transistor? Are you using a hydraulic/pneumatic analogy for a semiconductor device? \$\endgroup\$
    – Andy aka
    Mar 19, 2023 at 10:49

1 Answer 1


The Answer: I have found an answer to my question. I needed to put the voltage-limiting 5V (R2) resistor on the collector side of the transistor, next to the motor transistor. This keeps the voltage changes low as the voltage of the battery drops. Then, I needed to limit the current flowing from my microcontroller to the base of the transistor using a resistor (around 1.3Kohm for 2mA).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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