

A rocker switch is a type of electrical switch that toggles between two positions, typically used to control power to a device. It features a rectangular or oval shape that rocks back and forth to open or close the circuit. Rocker switches are widely used in various applications due to their simplicity, durability, and ease of operation.








The pin configuration of a rocker switch depends on its type. Below are examples for SPST and DPDT configurations:
| Pin Number | Label | Description |
|---|---|---|
| 1 | Input (Line) | Connects to the power source |
| 2 | Output (Load) | Connects to the device being powered |
| Pin Number | Label | Description |
|---|---|---|
| 1 | Input 1 | First input for pole 1 |
| 2 | Output 1A | First output for pole 1 (position A) |
| 3 | Output 1B | First output for pole 1 (position B) |
| 4 | Input 2 | Second input for pole 2 |
| 5 | Output 2A | Second output for pole 2 (position A) |
| 6 | Output 2B | Second output for pole 2 (position B) |
Below is an example of using an SPST rocker switch to control an LED with an Arduino UNO:
// Define pin connections
const int switchPin = 2; // Rocker switch connected to digital pin 2
const int ledPin = 13; // LED connected to digital pin 13
void setup() {
pinMode(switchPin, INPUT_PULLUP); // Set switch pin as input with pull-up resistor
pinMode(ledPin, OUTPUT); // Set LED pin as output
}
void loop() {
int switchState = digitalRead(switchPin); // Read the state of the switch
if (switchState == LOW) { // If the switch is pressed (LOW due to pull-up)
digitalWrite(ledPin, HIGH); // Turn on the LED
} else {
digitalWrite(ledPin, LOW); // Turn off the LED
}
}
Switch Not Working:
Switch Overheating:
Switch Fails to Toggle:
LED Flickering When Used with Arduino:
By following this documentation, you can effectively integrate a rocker switch into your projects and troubleshoot common issues with ease.