I am awfully new to circuit design and a little confused on some of the things I can and cannot do here, so please bear with me.

In a simple Arduino project, I am trying to control the output of an 8-ohms, 300mW loudspeaker from three separate digital control pins, using the circuit below.


simulate this circuit – Schematic created using CircuitLab

I want each of the Pins to represent a different output level: Pin1=Loud, Pin2=Medium, Pin3=Low, etc. The user activates the Pins by switching them HIGH, thus activating the NPN transistor and allowing current to flow through the load side (at least that's what I think I am doing).

I have the following hardware:

  • One source of power: 5V regulated output from a Adafruit PowerBooster via a 3.7v LiOn Battery.
  • one 8 ohms loudspeaker, 300mW (that's all what the datasheet says),
  • 3, 2N2222ATA NPN (1A, 40V, I think 100hFE) transistors for the switches,
  • A 3.3V arduino to control the Digital Pins.

The circuit works (...), but I have no idea if it is safe and if I am exposing any of the parts to undue harm and crucially, if it will last and not destroy itself over time. - I have no idea what base resistors I should use on the base of the three transistors (Rb1, Rb2 and Rb3: at the mom, I am blindly using 1K for all three), and I have no idea if my transistors are fit for the task. - I am slightly worried about a short circuit in the case where Q1 is activated. I have decided NOT to use any resistor here, because I wanted full output and did not reach the sound level I wanted, but fear this might not be super safe...

So, here is my question:

  1. Is this circuit a viable answer to my problem? In particular, I don't know if this is good practice to place load resistors (RL1 and RL2) the way I have and if not using any resistor on the Q1 collector is a good idea.
  2. Is it safe for the Arduino?
  3. Could you help me calculate what base resistors I should use?
  4. Are these transistors appropriate for this task?

I hope I have said it all.

Thanks in advance for the expertise provided.

Edits (following remarks/suggestions):

  • Added RL1 resistor (10Ohms, 1W to dissipate heat)
  • Modify base Resistors Rb1, Rb2 and Rb3 to 510ohm from 1k.
  • 1
    \$\begingroup\$ It's not clear what you are trying to achieve/design. \$\endgroup\$
    – Andy aka
    Commented Nov 28, 2018 at 13:36
  • \$\begingroup\$ What Andy says and: Q1 will very likely be destroyed as too much current can flow through it. The speaker might suffer damage as well. You might be drawing too much current from the 5V line. The 50 ohm resistor might get too hot. You're not using the speaker in a proper way as the current can only flow in one direction. This contraption cannot produce any sound that will be pleasant to your ears. Circuit design requires learning about circuits, you just slapped something together, it is not going to do anything useful. \$\endgroup\$ Commented Nov 28, 2018 at 13:44
  • \$\begingroup\$ Make sure you put a cap, say 10uF or 100uF, between the speaker and the transistors. You only want AC to go thru the speaker - if you hit it with DC, then then the cone will just go to its extreme and sit there, and the voicecoil possibly burn up. Say the 2n2222 has a Vce of 0.6V, then the max voltage across the speaker is ~ (5V - 0.6V)/8 ohm = 0.55A, and power dissipated P=IV = .55A x 4.6V = 2.53W. So that would smoke the speaker for sure if the power supply could source that much current and the transistor (which is only rated for 500mA max) didn't burn up first. \$\endgroup\$
    – CrossRoads
    Commented Nov 28, 2018 at 14:58
  • \$\begingroup\$ I thought it was clear what I was trying to achieve, but here we go again: Operate a single Speaker at different sound levels using three gates (here high, medium, low) operated by three distinct arduino Pins. Of course, that's the design I imagined, and it appears flawed... so pardon me if I say that if it worked great, I wouldn't be here asking experts how to do it \$\endgroup\$
    – Jeruinsky
    Commented Nov 28, 2018 at 15:28

2 Answers 2


you shouldn't output a digital signal from the arduino. Instead connect it to one of the pwm pins and use analogwrite to 127 when you want to play a sound and use the setPwmFrequency method to adjust the frequency you want to play on the speaker.

Actually outputing an ac signal will probably fix your loudness issue as well.

A capacitor between the speaker and the transistors is a good idea. and you should also put a resistor on Q1 so that you leave the transistor in a saturated state which will keep it from getting hot and burning out. the 1k resistors on the base is a good value.

  • \$\begingroup\$ thank you for your answer. I feel helped here for the first time ...! At the moment I am sending a tone() directly to the digital Pin which, I have read, is similar to using a PWM approach, and allows me to select the frequency but the level was left out of control... How exactly should I place the Cap between the Speaker and Transistor? To ease things a little (and help me do my homework), would you have a link you could share showing an example? I am new to this, and confess ignorance (+ I am building a toy for my kids for xmas and clock is ticking..). Again, thank you. \$\endgroup\$
    – Jeruinsky
    Commented Nov 28, 2018 at 16:21
  • \$\begingroup\$ When you say "use analogwrite to 127" do you mean the instruction analogWrite(myPWMPin, 127); ? Why 127? \$\endgroup\$
    – Jeruinsky
    Commented Nov 28, 2018 at 16:25
  • \$\begingroup\$ 127 is roughly half of 255. which will output a 50% duty cycle square wave. I will draw you up a schematic of how you should connect the transistors \$\endgroup\$ Commented Nov 28, 2018 at 16:34
  • \$\begingroup\$ ughh actually the circuit you have is adequate. the electrical engineer in me wants to design an actually amplifier but honestly you don't need it. change q1 to something that will handle more current (1a should be good) and change rb1 to a 510ohm resistor. it might blow out your speaker but if you need it loud.... you need it loud. \$\endgroup\$ Commented Nov 28, 2018 at 16:43
  • 1
    \$\begingroup\$ If you want it loud, and you're limited to a 5V supply, then change to a 4 ohm impedance speaker with good sensitivity like this one mpja.com/4-Ohm-Mini-Speaker/productinfo/14618+SP and use logic level MOSFETs such as IRL540 vs NPN transistors. Then you can get maximum voltage across the speaker for more current and louder sound. Power = V*V/R, so 5V x 5V / 4.06 ohm = ~6W. (~0.06 ohm Rds with Vgs = 4.5V) 2N2222 is not intended to carry that kind of current. digikey.com/product-detail/en/infineon-technologies/IRL540NPBF/… Need the cap. \$\endgroup\$
    – CrossRoads
    Commented Nov 29, 2018 at 14:58

First there seem to be a small mistake in your circuit. The wire between the top of Q1 and top of Q2 must be a mistake. Otherwise the circuit seems fine and I would next consider the values of RL1, RL2 and RL3.

One critical aspect is the maximum current that can flow:

1) The current flowing from the PINs through the 1KOhm resistor can not exceed 5mA. The arduino pins are rated for 20mA with a total of 40mA for all pins. So that looks save.

2) The current flowing through Q1 when only it is activate is limited by the speaker and RL1. I = 5V / (8Ohm + RL1). Say you remove RL1 then you have 5V / 8Ohm = 0.625A. Is Q1 rated for 0.625A? RL1 must be large enough to keep the current within bounds.

3) The current through the speaker is maximal if all Q1 - Q3 are activated. This is a bit more complex but 1/R = 1/RL1 + 1/RL2 + 1/RL3 gives you R = 7.964Ohm. So the total current is `I = 5V / (8Ohm + 7.964Ohm) = 0.313A. Is the speaker rated for 0.313A?

If you keep the current within specs then it should be save. Adjust RL1, RL2 and RL3 to stay within the limits of your components.

Next I would reconsider the circuit. You are using 3 pins to get 3 different voltage levels (+0V so 4 altogether). You didn't mention combining pins but that would give you 8 different voltages. Given your circuit the voltages you can reach would be hard to work with. If you instead switch to a Logarithmic resistor ladder (or R-2R ladder) then you would be implementing a DAC (digital to analog converter).

If you only need 4 Levels then 2 pins would suffice.

PS: For a speaker to make a noise you have to switch the current on and off quickly. So those currents above would only flow for a short time and you could exceed the allowed sustained current. But what if your code crashes and stops turning off pins. Best to calculate for pins remaining on and then you are well below any limit.

  • \$\begingroup\$ @Gaswin, a big thank you for your answer. Yes, you were right, the trace between Q1 and Q2 was a typo (edited). The pins are not meant to be all HIGH at the same time, but only one of them. The speaker is 300mW rated, but the datasheet doesn't mention anything about Max current. Thanks for this point. The 2N2222 is max 1A rated, so should be fine. For safety, I should maybe use 1.5A. Of course, I will study your suggestion for a Log resistor ladder which sounds more elegant. \$\endgroup\$
    – Jeruinsky
    Commented Nov 29, 2018 at 20:48
  • 1
    \$\begingroup\$ very good answer. one thing you missed is the maximum current that can flow also depends on how much current is flowing through the base of the transistor and the transistors gain. a typical gain for a 2n2222 is 100 meaning the maximum current through the collector would be 100 * .005 = 500 mA which without RL1 this will put the transistor in the active region causing it to dissipate power and will subsequently get hot. Now that RL1 is 10 ohms the transistor will no longer get hot but RL1 will now be dissipating the power of roughly 770 mW. therefore you will need at least a 1w resistor. \$\endgroup\$ Commented Nov 30, 2018 at 14:18
  • \$\begingroup\$ but this also means you are waisting energy that would otherwise be going into the speaker making it louder. instead you should should change rb1 to 510 ohms which is still in spec of the 20mA output of the arduino and will now output up to 1A of current at the collector. then you will not need rl1. \$\endgroup\$ Commented Nov 30, 2018 at 14:18
  • \$\begingroup\$ @Daniel. Thanks again. Will test and hopefully, that will be it. \$\endgroup\$
    – Jeruinsky
    Commented Nov 30, 2018 at 15:37
  • \$\begingroup\$ @jeruinsky You might intent to only ever set one pin HIGH. But maybe you make a mistake? It's easy to crash while developing and get the pins in any random state. So I would design the hardware to cope with any pin state. \$\endgroup\$ Commented Dec 5, 2018 at 12:55

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.