Hey everyone! I'm working on a small portable speaker project that uses a couple of tiny class D amps (PAM8403 2x 3W). Originally, I planned to power it using my Pixel 9's USB-C port, but it turns out the headphone adapter I bought is only for charging the phone. Right now, I'm powering it with 3 AA batteries. Here's where I need your help: I'd really like to have the option to power the speaker with either the AA batteries or USB, but I want to ensure that I can't accidentally use both at the same time. How should I wire this up safely? I have a spare terminal block for a cleaner install, but I'm not sure about the wiring. Do I need a switch, and if so, how would that work? Alternatively, is there a chance I'm overthinking this and it's not a huge risk? Thanks!
2 Answers
You might want to use a simple SPDT (Single Pole Double Throw) switch. It would let you choose between battery power and USB power, with an off position in the middle. Just wire the battery and USB to the two outer terminals, and connect the amp to the center terminal. This way, you’ll have control over which power source is active without the fear of accidentally mixing them up!
Another option is to use diodes for the power sources. You can connect the battery to the amp through a 1N5819 diode and the USB power through another 1N5819 diode. This setup will prevent any interference between the two power sources, allowing you to use them safely without worry.
That’s a cool idea! Thanks for sharing this approach!

Just to clarify, would I connect both grounds to the center too, and then one hot wire to each side? I struggle with switch wiring, but this seems like a solid solution!