How to Interface Relay with Arduino Nano
RELAY: A relay is a electromagnetic mechanical ON/OFF switch type. It is used to low power (Voltage or Current) circuit to switch high power drive. It is an electric switch that operates like open and close switch.
This type of relay is not able to connect directly to MCU. Because the MCU can sink is only 15mA while relay needs 100mA
So we need Transistor to interface relay with micro-controller.
Here below given circuits works like a transistor as a electronic switch. When we need more number of relay we can use ULN2003 high voltage and high current darlington transistor array.
each darlinton pari can be operated directly with TTL output or CMOS devices. It operating voltage is maximum 50V and output drive current is 500mA.
Simple Transistor Drive circuit:
Complete micro controller with ULN2003 8 relay drive circuit given below.
Simple S program for the above circuit.
#include
sfr out=0xA0;
sfr Switch=0x90;
unsigned int x;
int main ()
{
while(1)
{
if(Switch==0xFE)
{
out=0x01; // lamp switch
for( x=0;x<2000;x++);
}
else if(Switch==0xFD)
{
out=0x02; // motor switch
for( x=0;x<2000;x++);
}
else
out=0x00;
}
}
APPLICATION OF THE ULN2003.
1. It is used for relay drive.
2. Stepper motor application.