I'm working on an ugly Christmas sweater with a Lilypad Arduino.

Previously it was setup to power LEDs on each side of the sweater using just the voltage from the digital output pins (alternating sets of LEDs to the beat of the music), while also operating an inductive buzzer (connected to a PWM output on pins 5 and Arduino gnd) to play Christmas tunes via modulation. This was obviously pretty under-powered and I'd like to nearly deafen/blind my friends with this project.

So this year is V2 that uses transistors as switches to pump closer to 18V from 2x 9V batteries to the LEDs.

I was having an issue getting this setup to use a separate power supply and still operate properly with the buzzer. I'm using NPNs (TIP31) that are setup the following way (from memory, so hopefully I recounted it right, but the setup is functional):

  • Base -> Arduino output pin
  • Collector -> GND on the Arduino board
  • Emitter -> LED (-)
  • V+ -> LED (+)
  • V- -> GND on the Arduino board

V+ = 18V via 2x9V batteries

Arduino powered by a separate onboard battery.

Simplified schematic attempt below (doesn't show 2nd set of LEDs and 2nd transistor)


simulate this circuit – Schematic created using CircuitLab

My issue was that, when the buzzer is connected (even if its not being operated) the LEDs were staying lit. I'm pretty sure it has to do with the Arduino board and the separate power supply for the LEDs sharing a common ground. Disconnecting the ground from the (-) terminal of the buzzer confirms this.

Is there some way I can set this circuit up to have separate grounds, and would that even help? I figured I could use optoisolators to fully isolate the circuits, but I don't have time to order any in. Is there a solution simply using the NPN transistors I have available? Total novice here, so please bear with me!

Thanks in advance!


1 Answer 1


Your NPN power transistor seems to be connected up wrongly.

I'd expect something like this ...


simulate this circuit – Schematic created using CircuitLab


  • R1 limits base current and protects P1. \$R_1 = 5V - V_{BE(sat)} / I_B(20mA?)\$
  • R2 limits LED current. \$R_2 = (18V - V_{LED} )/ I_{LED}\$
  • Q1's collector is connected to the LED's cathode.

Perhaps your LED is actually an 18V LED module that has current-limiting built in?

Note: I believe piezo buzzers don't draw much current, you probably don't need a TIP31 to drive it. Check the specs and choose a more suitable transistor. To be connected as shown, the piezo buzzer should be rated for more than 18V.

  • \$\begingroup\$ OP indicates a desire to deafen as well as blind his/her Xmas sweater victims. If one presumed the piezo would be louder running directly off 18v than it would be if powered from the microcontroller pin, would you just essentially duplicate the Q1 setup with another TIP31 functioning as a low side switch for the piezo? I would guess R1 stays in place but depending on the buzzer maybe R2 goes? \$\endgroup\$
    – mikeY
    Dec 4, 2013 at 15:55
  • \$\begingroup\$ @mikeY: Those are good points. \$\endgroup\$ Dec 4, 2013 at 15:59
  • \$\begingroup\$ Good question mikeY - I have a new piezo spec'd for 3-12VDC so diverting more voltage to it may be necessary. Going to see how it sounds relative to the smaller one I had going previous when running straight off the board first. I'll give this a shot when I get home. Appreciate the quick response! \$\endgroup\$
    – ccrook
    Dec 4, 2013 at 16:09
  • \$\begingroup\$ Just to make sure, because the page here for the old piezo mentions using 2 I/O pins for it: If I did use a second IO pin instead of ground, it is still effectively the same circuit if that second IO pin is set LOW? \$\endgroup\$
    – ccrook
    Dec 4, 2013 at 16:20
  • \$\begingroup\$ This is RedGrittyBrick's answer so I don't want to steal his thunder, but I would be inclined follow this set up: lilypadarduino.org/?p=436 at least initially. I was asking questions above because I didn't know and we didn't have the specs on the piezo; with the additonal information a little Google suggests the above link is the way to go. \$\endgroup\$
    – mikeY
    Dec 4, 2013 at 16:39

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.