The KY-020 2-Channel Relay Module is an electronic device that allows a low voltage or low current signal to control a higher voltage circuit. It is commonly used in automation projects, home appliances control, and switching devices like lights, motors, or heaters. The module features two independent relays, each with its own circuitry and status LED, providing a visual indication of the relay operation.
Pin Number | Description | Type |
---|---|---|
1 | VCC | Power |
2 | GND | Power |
3 | IN1 | Control |
4 | IN2 | Control |
5 | Relay 1 Normally Open (NO) | Switch |
6 | Relay 1 Common (COM) | Switch |
7 | Relay 1 Normally Closed (NC) | Switch |
8 | Relay 2 Normally Open (NO) | Switch |
9 | Relay 2 Common (COM) | Switch |
10 | Relay 2 Normally Closed (NC) | Switch |
// Define relay control pins
const int relay1Pin = 2;
const int relay2Pin = 3;
void setup() {
// Set relay pins as outputs
pinMode(relay1Pin, OUTPUT);
pinMode(relay2Pin, OUTPUT);
}
void loop() {
// Turn on relay 1
digitalWrite(relay1Pin, HIGH);
delay(1000); // Wait for 1 second
// Turn off relay 1
digitalWrite(relay1Pin, LOW);
delay(1000); // Wait for 1 second
// Turn on relay 2
digitalWrite(relay2Pin, HIGH);
delay(1000); // Wait for 1 second
// Turn off relay 2
digitalWrite(relay2Pin, LOW);
delay(1000); // Wait for 1 second
}
Q: Can I control the KY-020 with a 3.3V microcontroller? A: Yes, but ensure the control signal meets the LOW trigger voltage threshold.
Q: Is it safe to switch AC mains with this module? A: Yes, but take proper precautions to avoid electric shock and adhere to electrical safety standards.
Q: Can I use PWM to control the relays? A: No, relays require a stable HIGH or LOW signal to switch states. PWM may cause erratic behavior.