2 channal relay

From SainSmart Wiki
Jump to: navigation, search

Sainsmart 2-Channel 5V Relay Module for Arduino DSP AVR PIC ARM

Take two way relay for an example. Relay IN1, IN2 should be connected to SainSmart uno/2560 pin’s 8, 9. VCC and GND should be connected to uno board’s +5V和GND. The picture below is for the explanations of the usage of two way relay module’s pins. They two are the same so I only explain one of them.

SainSmart 2-ch 5V relay.jpg

Connect two way’s COM to +5V and “NO”to the positive pole of the LED which we should control. The LED will shine when the relay is power-on. Then, connect IIC LCD1602’s VCC and GND to +5V and GND. Connect SDA and SCL to A4, A5.

When link the circuit, connect the two “NO”s to the red and green positive pole respectively. Afterward, connect the two negative poles with 330Ω resistances respectively. The other parts of the resistances should be connected to GND. After that, download the texting program below to the UNO board so that you know whether it is “on” and “off” of the two way relay by the LCD.

void setup() {

 pinMode(relay1,OUTPUT); // Define port attributes as output; 
 pinMode(relay2,OUTPUT); 
 lcd.init();         // initialize the lcd 
 lcd.init();        // Print a message to the LCD.
 lcd.backlight(); 

}

void loop() {

 digitalWrite(relay1,HIGH); // relay1 is power-on; 
 digitalWrite(relay2,LOW); //relay2 is power-off; 
 
 lcd.setCursor(0,1);
 lcd.print("relay1=ON, relay2=OFF ");
 lcd.setCursor(0,0);
 lcd.print("www.SainSmart.com ");
 lcd.scrollDisplayLeft();
 delay(1000); 
 digitalWrite(relay1,LOW); //relay1 is power-on; 
 digitalWrite(relay2,HIGH); //relay2 is power-off; 
 lcd.setCursor(0,1);
 lcd.print("relay1=OFF, relay2=ON ");
 lcd.setCursor(0,0);
 lcd.print("www.SainSmart.com ");
 lcd.scrollDisplayLeft();
 
delay(1000);

How to buy it

Click here to buy SainSmart 2-Channel 5V Relay Module