DPDT Switch
DPDT Switch
A DPDT (Double Pole Double Throw) switch is an electrical component that allows an electrical circuit to be connected or disconnected from two separate circuits. It is a type of switch that has two input terminals, two output terminals, and a common terminal, enabling it to control two separate circuits simultaneously.
The primary function of a DPDT switch is to act as an electrical switch that can connect or disconnect two separate circuits. When the switch is in the "on" position, it connects the common terminal to one set of input and output terminals, and when it is in the "off" position, it connects the common terminal to the other set of input and output terminals. This allows the switch to control the flow of electrical current between the two circuits.
12V to 240V AC/DC
1A to 10A
<10
>100M
-20C to 85C
Varies depending on the physical construction
UL (Underwriters Laboratories) certification
CE (Conformit Europene) certification
RoHS (Restriction of Hazardous Substances) compliance
REACH (Registration, Evaluation, Authorization, and Restriction of Chemicals) compliance
DPDT Switch Documentation
Overview
A Double Pole Double Throw (DPDT) switch is a type of electrical switch that can connect two independent circuits, each with two states (on/off). It has six terminals, with two poles that can be connected to two different circuits, and each pole has two throws that can be connected to either a normally open (NO) or normally closed (NC) contact. The DPDT switch is commonly used in IoT applications to control multiple devices or circuits with a single switch.
Pinout
The typical pinout of a DPDT switch is as follows:
Pole 1:
+ Terminal 1: Common (COM)
+ Terminal 2: Normally Open (NO)
+ Terminal 3: Normally Closed (NC)
Pole 2:
+ Terminal 4: Common (COM)
+ Terminal 5: Normally Open (NO)
+ Terminal 6: Normally Closed (NC)
Code Examples
### Example 1: Controlling Two LEDs with a DPDT Switch (Arduino)
In this example, we will use a DPDT switch to control two LEDs, each connected to a separate circuit.
```cpp
const int led1Pin = 2; // LED 1 connected to digital pin 2
const int led2Pin = 3; // LED 2 connected to digital pin 3
void setup() {
pinMode(led1Pin, OUTPUT);
pinMode(led2Pin, OUTPUT);
}
void loop() {
int switchState = digitalRead(4); // Switch connected to digital pin 4
if (switchState == HIGH) {
digitalWrite(led1Pin, HIGH);
digitalWrite(led2Pin, LOW);
} else {
digitalWrite(led1Pin, LOW);
digitalWrite(led2Pin, HIGH);
}
delay(50);
}
```
In this example, when the switch is in one position, LED 1 is turned on and LED 2 is turned off. When the switch is in the other position, the states of the LEDs are reversed.
### Example 2: Controlling a Relay Module with a DPDT Switch (Raspberry Pi)
In this example, we will use a DPDT switch to control a relay module, which in turn controls a larger device such as a lamp or a motor.
```python
import RPi.GPIO as GPIO
# Set up GPIO mode
GPIO.setmode(GPIO.BCM)
# Set up GPIO pins
switchPin = 17
relayPin = 23
# Set up GPIO as inputs/outputs
GPIO.setup(switchPin, GPIO.IN)
GPIO.setup(relayPin, GPIO.OUT)
try:
while True:
switchState = GPIO.input(switchPin)
if switchState == GPIO.HIGH:
GPIO.output(relayPin, GPIO.HIGH)
else:
GPIO.output(relayPin, GPIO.LOW)
# Wait for 50ms before checking the switch state again
time.sleep(0.05)
except KeyboardInterrupt:
# Clean up GPIO on exit
GPIO.cleanup()
```
In this example, when the switch is in one position, the relay is turned on, connecting the larger device to the power source. When the switch is in the other position, the relay is turned off, disconnecting the device from the power source.
These examples demonstrate how a DPDT switch can be used to control multiple devices or circuits with a single switch, making it a versatile component in IoT applications.