Okay, so a usb port has 4 pins, a ground, two I/O pins, and a (may or may not be switchable) 5V pin. I had an idea to to connect one of the pins to the base of a transistor. Then I would rip the button out of power strip, and connect the other two leads of the transistor where the switch used to be.

  • If I connect it to a data pin, it would turn the thing on and off essentially at random. Since I want to hook this up to a Christmas lights, that would be awesome!
  • If I connect it to the 5V pin, I could switch it on and off by turning the USB port on and off.

My question is, is this safe/would it work? What transistor should I use (since I'm writing the software, the software could accommodate the specific transistor if needed.)


closed as off-topic by Tom Carpenter, Leon Heller, Daniel Grillo, PeterJ, Dave Tweed Dec 5 '15 at 13:08

  • This question does not appear to be about electronics design within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    \$\begingroup\$ NO!. Please, for goodness sake, don't. The switch will most likely be directly connected to the mains, so connecting a "transistor" across it will most likely result in something going bang (probably the transistor, the fuse, and your computer), possibly fire, and optionally death. If you have no mains experience, don't touch it. \$\endgroup\$ – Tom Carpenter Dec 3 '15 at 15:40
  • 1
    \$\begingroup\$ Also, the USB pins are not usable in this way. They use a specific protocol for communication (not general purpose IO) which will not help you control a set of lights - the data speed is so fast that you wouldn't see anything but the lights maybe being dimmer than usual. \$\endgroup\$ – Tom Carpenter Dec 3 '15 at 15:42
  • \$\begingroup\$ "by turning the USB port on and off" -- I doubt that's possible via software. \$\endgroup\$ – JimmyB Dec 3 '15 at 15:44
  • \$\begingroup\$ @TomCarpenter Why would they do that (why would that send the all that voltage through the switch)? \$\endgroup\$ – PyRulez Dec 3 '15 at 15:44
  • 4
    \$\begingroup\$ I'm voting to close this question because its nothing but dangerous... You can buy products for switching mains via USB, which is only marginally less dangerous unless you know what you are doing - but then the question would become recommendation of products which is off topic. \$\endgroup\$ – Tom Carpenter Dec 3 '15 at 15:49

No. Nothing you have mentioned will work, and is in fact dangerous. I strongly advise you not to experiment here. First, the data pins on a USB port are just that, DATA. Not simple I/O. Second, the power pin is not really controllable. And if you hook up a transistor the way you describe, you will probably destroy whatever the USB port is plugged into and the transistor.

  • \$\begingroup\$ Good thing I asked before doing it \$\endgroup\$ – PyRulez Dec 3 '15 at 15:46

I found this after 5 seconds of Google searching. You sound like you have no idea what you're doing, so try not to kill yourself.



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