Part

Slide switch

Two positions, held where you leave it.

See every part
  • 3 pins
  • In 34 projects
  • In 28 lessons
Drawn live by the editor's own code, at the size you see it.
At a glance

The Slide switch in brief

What it is, and where it sits on the bench.

A slide switch is the small three-legged SPDT switch in most kits: sliding the knob joins the middle leg, the common pole, to one outer leg or the other. Mokxi’s part does exactly that, with pin 2 tied through a 50 milliohm contact to pin 1 or pin 3 and the unselected throw left genuinely open, so anything hanging off it floats the way it would on a breadboard. No pin is an input or an output: the contact passes whatever is on either side in either direction, so it works as a logic-level input or a supply selector. To read it from an Arduino Uno or ESP32, wire pin 2 to a GPIO and the outer legs to ground and to the supply, using 3.3 volts on an ESP32, never 5. The common mistake is wiring only one throw and expecting the other position to read as a clean 0 or 1, when that pin is floating unless a pull resistor holds it. There is no contact bounce and no travel time between the throws.

Family
Inputs
Pins
3
Pins

3 pins

Named as the editor names them, so a wire lands where you expect it.

Pin
What it does
1
One throw.
2
The common pole.
3
The other throw.
How to use it

How to use a slide switch with an Arduino

The middle leg goes to a digital pin and one outer leg to GND. Set the pin to INPUT_PULLUP in setup(), and digitalRead() gives LOW with the slider on the grounded side and HIGH with it on the other, where the pin is held up only by the pull-up. That is how the elevon mixer here picks between its two modes on pin 4, with the third leg left unwired.

Leave out INPUT_PULLUP and the unwired position reads Floating instead of HIGH, because nothing drives the pin at all. Wiring the third leg to 5 V instead gives a driven HIGH in both positions and needs no pull-up at all. Either way, read the switch in loop() rather than once in setup(), so flipping it while the sketch runs changes the mode.

Part pin
Board pin
2 (the common pole)
Pin 4
1
GND
3
Not connected

The same wiring works on an ESP32 or a Pico; if you wire the third leg to a supply there, use 3.3 V, never 5 V.

Arduino Uno: RC elevon mixerlive0.000 s 0.00x
Hold the button
This is the simulator itself, running here. Click anything to open it in the editor.
Reading the mode switch, from the elevon mixer
const int MODE_PIN = 4;
void setup() {
  pinMode(MODE_PIN, INPUT_PULLUP);
}
void loop() {
  bool elevonMode = digitalRead(MODE_PIN) == HIGH;
}
How it is modeled

What is true about the Slide switch, here

In its help article’s own words: what the simulation gets right, and where it stops.

Modeled

No pin is treated as an "input": a slide switch passes whatever is on one side through to the other, in either direction, which is what makes it just as useful as a supply selector as it is as a logic-level input.

Not modeled

No contact bounce. A real slide switch chatters for a millisecond or so on the way across, but nothing in the firmware library needs it modeled, and a silent approximation beats a wrong one. The pushbutton is where bounce is modeled, because a debounce lesson actually needs it there. Nor is there any travel time: the pole leaves one throw and arrives at the other in the same instant, where a real slider is genuinely open for a moment in between. There is no contact resistance drift, no wear and no current rating.

From Slide switch (SPDT), in full.

Projects

See the Slide switch in a project

34 built-in projects use it. Each opens in the editor, already wired.

Boards

The boards it is shown on

Each of these 3 boards has a built-in project with the Slide switch in it.

Wire up the Slide switch

Open the editor and push it into the breadboard. It is free, and it runs on your own machine.