TPL-13Templates/Slide Switch
Slide Switch
SPDT slide switch wired between GND and 5V. The common pin reads LOW or HIGH depending on switch position. Click the switch on the canvas to toggle it — the Serial Monitor shows the state.
Open in Playgroundbeginner · switch · digital input · serial · SPDT
FIG. 1Slide Switch · circuitTPL-13
02Sketch
sketch.inoArduino C++
13 lines
// Slide Switch — read switch position
const int SW = 4;
void setup() {
pinMode(SW, INPUT);
Serial.begin(9600);
}
void loop() {
int state = digitalRead(SW);
Serial.println(state == HIGH ? "Switch: ON" : "Switch: OFF");
delay(300);
}03Components
- 01Arduino Uno
- 02Slide Switch (wokwi-slide-switch)
04Wiring
| Component pin | Arduino pin |
|---|---|
| Pin 1 (left position) | GND |
| Pin 2 (Common) | Pin 4 |
| Pin 3 (right position) | 5V |
Ready when you are
Have a circuit in mind?
No hardware, no installs — a browser is enough.