Interfacing Relay to MCU

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.
uln2003 app
Simple Transistor Drive circuit:
Complete micro controller with ULN2003 8 relay drive circuit given below.
relay to mcu

Simple S program for the above circuit.
sfr out=0xA0;
sfr Switch=0x90;
unsigned int x;
int main ()

out=0x01; // lamp switch
for( x=0;x<2000;x++);
else if(Switch==0xFD)

out=0x02; // motor switch
for( x=0;x<2000;x++);
1. It is used for relay drive.
2. Stepper motor application.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.