A 2-Channel Relay Module is an electronic module that allows you to control two separate devices (such as lights, motors, or other high-voltage appliances) using a low-voltage control signal, like from a microcontroller (e.g., Arduino or Raspberry Pi). The module uses relays to isolate and switch high-power devices safely using low-power signals.
Here's a basic example where you use the relay module to control a light:
int relayPin1 = 7; // Pin connected to IN1 of relay int relayPin2 = 8; // Pin connected to IN2 of relay void setup() { pinMode(relayPin1, OUTPUT); // Set relayPin1 as output pinMode(relayPin2, OUTPUT); // Set relayPin2 as output Serial.begin(9600); // Start serial communication } void loop() { // Turn on Relay 1 (light ON) digitalWrite(relayPin1, HIGH); Serial.println("Relay 1 ON"); delay(2000); // Wait for 2 seconds // Turn off Relay 1 (light OFF) digitalWrite(relayPin1, LOW); Serial.println("Relay 1 OFF"); delay(2000); // Wait for 2 seconds // You can control Relay 2 similarly (if you have a second device connected) }
setup()
, the pins connected to the relay module are set as OUTPUT.loop()
, Relay 1 is turned on for 2 seconds, and then turned off for 2 seconds.Origin:- China
Brand:- Generic