10% Off For Your First Order, Code:Elephant10

Arduino Project: 5V Relay

Posted by Fiona Su on



Relay is an automatic switch element with isolation function. It's widely used in remote control, remote sensing, communication, automatic control, mechatronics and electronic devices. It is one of the most important control elements.
In summary, it has below functions:
1)Expanding the control range: for example, when the control signal of the multicontact relay reaches a certain value, it can form different contact ways. At the same time switch on or off of multiple circuits.
2)Amplification: for example, sensitive relay and intermediate relay can control circuits of large power using a small amount of controlled quantity.
3)Synthetic signal: for example, when input more than one specific control signals to multiwound relay, achieve predetermined control effect after comparison and synthesis.
4)Automatic, remote control and monitoring: for example, combining relay on the automatic device to other electric equipment can realize automatic operation.

Matters needing attention:
rated working voltage: refers to the normal working voltage the relay coil needs,
Voltage control is the control circuit. It can be AC or DC voltage according to different models.
DC resistance: refers to the DC resistance of relay coil, multimeter.
Attract current: refers to the minimum current that the relay needs to generate suction action. During normal use, given current must be slightly larger than the operating current to guarantee stable operation of relay. Normally, the working voltage is 1.5 times of the coil’s. It cannot be more than the rated working voltage or coil will be burnt out due to high current.
Release current: Refers to the maximum current for the relay to gennerate release action. When the suction-state current reduces to a certain point, relay will return to its unenergized release state. The current here is far less than the suction current.
Contact switch voltage and current: refers to the load voltage and current the relay allows. This determines the magnitude of control voltage and current. Use current no high than these values or relay contact will be damaged.
Hardware Required:

  • Arduino Board *1
  • USB Cable *1
  • 4N35 *1
  • 5V Relay *1
  • 4007 Diode*1
  • 8050 Transistor *1
  • Red M5 LED*1
  • 220Ω Resistor *2
  • Breadboard*1
  • Breadboard Jumper Wire*11

Connection for REV4:


Connection for Arduino Mega 2560 R3:


Sample Code:

int relay = 3; // relay turn-on trigger signal - active high;
void setup ()
pinMode (relay, OUTPUT); //define port attribute for the output;
void loop ()
digitalWrite (relay, HIGH); // relay conducted;
delay (1000);
digitalWrite (relay, LOW); // relay switch;
delay (1000);


You can have different ways to do the conduction and disconnection process. This is one way for your reference. Here, when S is in high level, relay switches to the on end. LED will be turned on or you can switch to NC end.
In the test result, you will see LED turning on and off in 1s interval.




Leave a comment

Please note, comments must be approved before they are published