The relay module is an electrically operated switch that allows you to turn on or off a circuit using voltage and/or current much higher than a microcontroller could handle. There is no connection between the low voltage circuit operated by the microcontroller and the high power circuit. The relay protects each circuit from each other.
The each channel in the module has three connections named NC, COM, and NO. Depending on the input signal trigger mode, the jumper cap can be placed at high level effective mode which ‘closes’ the normally open (NO) switch at high level input and at low level effective mode which operates the same but at low level input.
void setup()
{ pinMode(11,OUTPUT);
pinMode(10,OUTPUT);
pinMode(9,OUTPUT);
pinMode(8,OUTPUT);
}
void loop()
{ digitalWrite(11,LOW);
delay(4000);
digitalWrite(10, LOW);
delay(4000);
digitalWrite(9, LOW);
delay(4000);
digitalWrite(8, LOW);
delay(4000);
digitalWrite(11, HIGH);
delay(4000);
digitalWrite(10, HIGH);
delay(4000);
digitalWrite(9, HIGH);
delay(4000);
digitalWrite(8, HIGH);
delay(4000);
}
The components to be used are:
The figures below shows an alternate switching of the two relays every 4 seconds. A tick sound and a red LED would be observed.
Serves to power the part of the relays with the same Vcc of the opto-isolated part. If you want to separate the power supplies, remove the jumper and connect the external power supply between JD and GND without connecting the Arduino GND.
After removing the jumper cap, you need to power the jd-vcc separately as shown below: