Hello friends, first of all tell me how was EID ?? Enjoyed or not :)) Mine was a bit boring and didn’t enjoyed much. Let’s start the tutorial, before EID I have posted the first part of this tutorial in which I have explained the basics of relay and also its working and because of EID I couldn’t post the second part of it.

In today’s tutorial, we will see how to use relay with a microcontroller. The microcontroller I am gonna use here is PIC18F4552 but you can use anyone just need to change the syntax of coding but the logics will remain the same. Here, I am using ULN2003A to control Relays and from these relays we can control anything. Relay is a key component in almost every electronic circuit. It can be used as a switch and can also be used a voltage regulator.

Basics Idea

  • Relay I am using here is of 12V, I am using this one because its mostly used in projects.
  • Actually, we just control the coil portion of relay, so we send the signal to the relay coil. In simple words, we attach any pin of the PIC with one pin of relay coil and make the other pin to ground.
  • So now when we send the high signal from PIC it will make the relay pin to high and thus the coil actuated and when we make it LOW, the coil deenergized.
The Question is ???
  • But the real question is PIC gives 5V at its high signal but the relay is of 12V so how to convert this 5V signal into 12V.
What’s the Solution ???
  • The solution to this problem is ULN2003A.
  • ULN2003A is used in between PIC and the relay, so when the PIC sends the HIGH signal i.e 5V , ULN converts it to 12V and send it to relay and relay got actuated.

Circuit Diagram

  • Here’s the circuit diagram for this complete project.
  • Resistance R1 is just a pullup resistance.
  • LED is using for the indication,when relay is actuated LED goes ON otherwise OFF.
  • The programming portion is not much, just send high and low signals from PIC to ON and OFF the relay.


  • If you want to buy this project for learning then use our Order Form to place the order.
  • Fully working project with programming will be provided.
That’s all for today guys. If you guys have any problem in any part of this tutorial ask in comments, I will reply your queries. Till next tutorial ALLAH HAFIZ …. :))


Leave a Reply

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

Post comment