A rocker switch is a user-interface electronic component that operates as an on-off switch. The SPST (Single Pole, Single Throw) designation indicates that the switch has one input (pole) and one output (throw), making it a simple binary device that either completes or breaks a circuit. Rocker switches are commonly used in household appliances, office equipment, and industrial controls due to their ease of operation and reliability.
Pin Number | Description |
---|---|
1 | Input (Line Voltage) |
2 | Output (Load) |
Note: The pin numbers are for reference and may vary based on the manufacturer's design.
Q: Can I use a rocker switch with a DC circuit?
Q: Is it possible to replace a toggle switch with a rocker switch?
Q: How do I know if the rocker switch is in the on or off position?
If you're using a rocker switch with an Arduino UNO to control a device like an LED, here's a simple example code:
// Define the pin connected to the rocker switch
const int rockerSwitchPin = 2;
// Define the pin connected to the LED
const int ledPin = 13;
void setup() {
// Set the LED pin as output
pinMode(ledPin, OUTPUT);
// Set the rocker switch pin as input
pinMode(rockerSwitchPin, INPUT);
}
void loop() {
// Read the state of the rocker switch
int switchState = digitalRead(rockerSwitchPin);
// If the switch is in the 'on' position, turn on the LED
if (switchState == HIGH) {
digitalWrite(ledPin, HIGH);
} else {
// If the switch is in the 'off' position, turn off the LED
digitalWrite(ledPin, LOW);
}
}
Note: In this example, the rocker switch is assumed to be connected to the Arduino such that it closes the circuit when in the 'on' position, connecting the input pin to 5V. A pull-down resistor may be needed to ensure the pin reads LOW when the switch is open (off).