In this article we consider the work of Arduino with electromagnetic relays SH-05VDC (Figure 1). In this case, four module (each module – on a separate electrical circuit), but we will use only one relay module with four.
Purpose relays outputs the following
VCC: (+) supply.
In1 – In4: control relays outputs 1-4.
GND: (-) supply (ground).
In our case, VCC connected to + 5V Arduino, In4 to pin 2 Arduino, GND to GND Arduino.
The following sketches we will turn on and off every two seconds relay connected to the digital contact Arduino pin 2.
int Relay = 2;
digitalWrite(Relay, LOW); // relay is switched
digitalWrite(Relay, HIGH); // relay off
For clarity, I connected a bulb, which is part of the network and guided by our relay: