dolphinlabs
...
Doplhin labs
News

PIC18F4520-Relay Interfacing


 

         Program Statement: Interfacing of Relay with PIC18F4520 controller.

Connections: PORT RD0= Relay

 

Hardware connections for PIC184520 Board:

1.      Give supply to the Board with the help of adapter.

2.      Connect +5V pin of PIC controller to +5v supply and GND pin of controller to GND pin of supply.

3.      Connect RD0 pin of controller to RELAY

4.      Connect 12V pin of Relay interface block to +12v supply pin and GND pin of Relay to GND pin of supply.

 

Circuit Diagram:

 

 

Program Code:

#include<P18F4520.h>

#define relay PORTDbits.RD0 //define RD0 pin as relay

void delay();

void main()

{

TRISD=0X00; // make portD as output port

while(1)

{

relay=1; //make relay high

delay(); //call delay

relay=0; //make relay low

delay(); //call delay

}

}

void delay()

{

int i,j;

for(i=0;i<255;i++)

for(j=0;j<255;j++);

}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


Get SOCIAL







SAFE & SECURE SHOPPING

visa card master card maestro card
Maverick IT Industries Pvt. Ltd.