Introduction: USB Switch - New Warning on Use
Warning Note added May 18, 2015.
After using this to switch on electronics, it seems to have a side effect. When switching off an Arduino, the USB port is sometimes not responsive and requires a reboot of the computer. I'm not sure why this happens. It could be an issue with the data lines still being connect but the power is cut off. Use this design at your own risk.
We recently spent a couple of hours developing a power switch for the USB port. Some devices, like the Arduino, have no power switch. You have to unplug it in order to turn it off.
Most of the time leaving the Arduino running while you work on the code is not a problem. You can fix the code and upload the changes without having to turn it off. Worse case, you can use the reset button to fix any minor problems.
The problem happens when a sketch is controlling something, like a motor or speaker, leaving it running can be annoying or could even damage something. Pulling the plug is easy, but for us the USB plug is always inserted wrong, i.e., it takes three tries to get it right. It would be nice to flip a switch instead.
Step 1: Designing the Circuit in Eagle Cad
The original goal was to have a switch that directly plugged into the computer USB port at one end, and had a USB mini-B plug to go directly into the device. The USB mini-B plug is very common on cables, but we could not find a board mounted equivalent.
The next best option was to use a standard USB-A plug at one end and a receptacle at the other.
The next consideration was to design the device for easy etching on a single sided board. This requires SMT parts for both the USB plug and receptacle.
Our EagleCad libraries only had SMT for the plug. We kludged this by writing the schematic with the PTH part and then overlaying an extra plug over the receptacle in the board layout. This will spit out errors when you check the schematic, but it will give the correct pads on the schematic to make the board work.
Step 2: Prepare the Image for Etching.
The board file is then exported to pdf.
Then we took the board file and cleaned up any details we did not like in photo editing software. Since we were going to etch this part ourselves, we gave more clearance around the pads.
Don’t forget to mirror the image before transferring to your board.
Step 3: Final Files
Our first attempt had a flaw with the wire going to the LED. We fixed this with a jumper wire. Then we fixed the schematic.
If you build send us an e-mail and tell us how it worked.
Since we are happy with our first attempt, we have not built and tested the revised design. Use and modify at you own risk.
Note the schematic does not show a switch. We used three pin headers for the contacts and then spaced them out to match our switch’s pin spacing.
We included a way to add a power out connector if you want the 5V but not the USB connection.
The one bottom trace can be made by soldering a wire to the bottom of the board. Just drill the via to match your wire size.
If you do not have a spare PTC, you can solder in a zero ohm resistor. The PTC is better because it provides some current protection to your USB port. The computer may (?) have built-in protection, but how can you be sure.
If enough people are interested we would do a cleaned up DIY kit as a Kickstarter project. Send us an e-mail if you are interested.