On/Off Switches

In this guide, we'll walk through the steps to wire your own on/off switch. These little "Slide Switch JST adapters" come in handy for lots of projects where you need the ability to power the circuit on and off – which is like, every project! 

Being able to turn your project on and off can be pretty useful, if not very important!  It's also nice not to take apart your project just to power it down. That’s where an on/off switch is quite handy! I really find these handy because I think we’ve used them in so many of our projects – It’s kinda like the project you have to make before the actual project.

So, What Is This?

This little guy has a male JST connector on one end and a female JST connector on the other. Wired in-line with the voltage is a slide switch. This essentially opens/closes the voltage connection. So you can plug in a battery into the female connector, and plug in the male JST into your board. This way, you can easily "cut" the power from the circuit. This also allows you to disconnect the battery and leave the switch in the project – Handy when you need to recharge dead batteries!


The Adafruit Circuit Playground, Feather, FLORA and GEMMA all feature on-board female JST-PH connectors. This makes it easy to add power to your projects by simply plugging in a compatible battery. We found these type of connectors to be very useful and have made it into our standard for power connectors. Some of these board's do have on-board on/off switches but the problem with that is, if your board is embedded into a project, then you might not be able to get to it anymore. So having a way to break out that switch can be very useful in certain projects.

Power All The Things!

To power your portable projects, we have lots of different options for batteries. You'll be happy to know almost all of them feature a 2-pin JST connector. This means all of the batteries in the Adafruit shop will work with any board that may have a female JST-PH connector on board.


You'll need the following parts to build this project.

Tools & Supplies

You'll also find the following tools handy.

JST Switched Breakout

If your board doesn't have an on-board JST connector, you should use our JST breakout board. Just wire the voltage and ground on the PCB to your circuit. We also have a version with a built-in on/off slide switch! For some projects, you may find it useful to have the switch on-board. We also have a version without the switch. Pick the right one your project.

JST Extension with On/Off Switch

For some projects, you may find our premade JST extension cable with on/off switch suffice. This guy features a nice and tactile lacting button, housed in a protective enclosure. For wearables and large scale projects, you may find this more useful. Also a great option if you don't want to solder anything.

Author Notes:

I finally have a guide I can point people too when they need to build one of these before tackling a bigger project. I've probably made these little switch adapter for 90% of my projects, so it's nice to have a tutorial just on this. Even though they're all "different", the general steps are all about the same. Moving forward, I hope to link this guide in future projects so I can keep them short – Normally have to dedicate a page just for the switch slide ;-)

Think Before You Make

It's a good idea to plan ahead and think about how you'll be powering your projects on and off. Sometimes it's totally OK to just toss a power switch in, but if you plan it, you might avoid potential road blocks. 

When I first started making Adafruit projects, I'd just toss a slide switch into a 3D printed enclosure and call it a day – I quickly found that to be problematic, only because it's a pain to open up a project just to turn it off (especially when there's screws or glue involved!).

How long should the wires be?

This depends on the project. The length of wiring should be determined by the size of the project. Maybe the switch needs to be a certain distance away from the battery. Or maybe the switch needs to be further away from the circuit. Think about these factors to figure out how long the wires need to be. In some cases, for those really small projects, maybe it needs to be the shortest as possible.

Where/How will it be secured in the project?

Picking the best location for the power switch is just as important as the length of wire it needs to be. Will the power switch be easy to get to? It shouldn't be a pain to reach behind your project just to power it off. Does the location of the power switch make sense? Is it easy to accidentally power it on/off? Maybe it's better on the side than the back. Think about this so you can allocate real estate for the power switch.

Which type of switch should I use?

It does not have to be this type of slide switch. There's lots of different types and styles of power switches. It could be a bigger push button type, an arcade button or maybe even a rocker switch – just make sure its a "latching" type, and not the "momentary" type. Depending on the size of your project, you'll need to pick which one best fits your project.

Depending on your powering needs, you may need to get a beefier switch that can support a higher amount of amps/voltage. It's a good idea to check the datasheet of your power switch to ensure it's capable of handling your projects needs. Most of my projects tend to be around 5V, so they're very light on power – the breadboard friendly SPDT slide switch is my "goto" component for power switching. 

Now that you've done some ideation and planning (maybe wrote notes?), we can get started on wiring up our own slide switch. But first, a quick tip!

Helping Third Hand

The Helping Third Hand is a nice tool to have because it can hold things in place while you solder things together. The teeth from these little grabbers however tend to byte into wires. So here’s a little quick tip. You can add heat shrink tubing to make it easier on things when grabbing onto them. Just add a piece to each grabber and apply heat. This adds a layer of protection and also makes things look nice. So now we can work with wires and avoid getting those byte marks.

Female JST Connectors

Before we get started on soldering, I want to point out something of a preference of mine. The JST extension cable has a male and female JST connector. So, why am I using a separate "stand-alone" female JST connector if there's one already wired to the cable?

Mainly because I think the SMT right angle connector is much more durable than the one wired to the extension cable. I've accidentally got the tip of the soldering iron too close to one of these and melted it – The black colored ones are a bit more resilient towards heat. Which ever you prefer, you're free to use the one you want.

The Slide Switch

This particular slide switch features three separate pins. They have 0.1" spacing and snap in nicely into a solderless breadboard. The middle pin is connected to either the left or right pin depending on which way the slider is pushed.

Secure The Switch

Go ahead and secure the slide switch onto one of the grabbers on the helping third hands with the pins facing out. We'll need only two of the three pins to make our slide switch JST adapter. So we can remove one of them, either the far left or right, just not the one in the middle! I like to use flush diagonal cutters so the cut is close to the subtrate.

Prep The Switch

The pins are bit longer than we need, so we can trim them short by cutting them in half using wire cutters. Next, we'll tin the two remaining pins by applying a bit of solder to them. You can do this by touching the pin with the tip of your soldering iron and a strand of solder. Just a small amount is suffice. By tinning the pins, it makes it easier to attach wires to them. Tinning pins and wires essentially make them "stickier". After that, we can take down the switch and set it aside. We'll work on the male JST connector next.

Male JST Connector

The JST extension cable has a male JST connector wired on one of the ends, so we can use it in our slide switch JST adapter. First, we'll need to determine the "right" size for our project. In this example, I'm making it for an enclosure that will house an Adafruit Feather. I typically make it about the size of the enclosure. Note, the size of the wire should accommodate for the switch and JST connectors. Rule of thumb is to make it longer than you think is necessary – You can always trim it shorter. Although you can add more to the wire if it's too short, that just adds more steps =]

Split Ground + Voltage Wires

Next, I'll separate the two wires since we will be attaching different components to each. Doesn't have to be all the way, just enough separation for the two connectors. By the way, black wire is ground (or negative) and the red one is voltage (or positive). 

Heat Shrink

Heat shrink is like the duct tape of electronics. It's mainly used for insulating exposed connections, but I tend to use it for grouping wires together – Avoids rats nests and keep things nice and neat! I recommend using the 3/32" size tubing for this project. It's the smallest size and works pretty well for the 24 AWG wires from the JST extension cable. Cut off a small piece and slip it over your wire.

Prep Wires

Now that we have our ground and voltage wires separated, we can prep them for attaching them to the JST connectors.

Tin Wires

Secure the JST cable to the helping third hand. Using wire strippers, remove a small bit of insulation from the tips of each wire to expose them. Then, tin the tips by applying a small amount of solder to them. This will fuse the strands of wire together to prevent them from fraying.

Connect Voltage to Switch

Cut a small piece of heat shrink and slide it over the red (voltage) wire from the JST cable. Then, secure the slide switch back onto the helping third hand. Now we can connect the voltage wire to the switch by soldering it to one of the pins. Polarity doesn't matter here, so it can go on either pin. Next, we can slide the piece of tubing over the bare metal and apply heat to shrink in place. And with that, our wire is now connected to the slide switch

Prep Female JST

Next, we'll work on attaching the ground wire to the female JST connector. Secure the female JST connector to the helping third hand and tin the two pins with a bit of solder. Then, cut another piece of heat shrink and slide it over the ground wire coming from the JST cable.

Connect Ground to Female JST

Now we can connect the ground wire to the ground pin on the female JST connector. You'll need to get the polarity right, so make sure your soldering to the correct pin. The outer shell of the female JST connector has a little notch on the top surface to indicate the positive voltage connection. Solder the ground wire to the ground pin. Then, slide the piece of tubing over the exposed connection and heat to shrink in place.

Bridge Voltage Connection

Now we have the voltage and ground wires connected to their respected connectors. Next, we'll need a new piece of wire to connect the slide switch to the felame JST connector. Grab the other end of the JST extension cable (with the female connector) and measure a piece of wire for connecting the switch to the female JST connector. Cut the piece of cable and separate the two wires. We'll use the red one to keep the apperance of polairty consistant.

Prep Wire for Voltage 

Using wire strippers, remove a bit of insulation from the tips and apply some solder to tin the strands of wire. After that, we'll cut two more pieces of heat shrink and slide them onto the wire. Next, we'll attach this wire to the slide switch.

Connect Voltage to Switch

Secure the slide switch onto the helping third hands. Then, solder the red wire to the remaining pin on the slide switch. Slide the piece of heat shrink tubing over the exposed pin and apply heat to shrink it in place. And with that, we're done wiring the switch! Next, we'll attach the other end of the voltage wire to the female JST connector.

Connect Voltage to Female JST

Secure the female JST connector to the helping third hands and bring the voltage wire close to the pins. Then, attach the tip of the wire to the positive pin on the female JST connector by soldering the two together. Now we can slide the last piece of heat shrink over the exposed connection and set it in place. And thats it!

Customize Yours

There's a few ways to change the format to better fit your project. For small projects, you might find it more suitable if the slide switch connections are soldered at a right angle position. The length of the wires really do matter, so do a test fit and see if they're too long or short. If they're too long, you can shorten the wires and resolder things. Too short, and you'll have to add pieces of wire. If that's the case, you may find it easier to just swap out the short wires for a longer one. 

This guide was first published on Mar 22, 2017. It was last updated on Mar 22, 2017.