A relay is an electrically operated switch or an electro-mechanical switch. Relays are used where it is necessary to control an electronic circuit by a low-power signal or where several circuits must be controlled by one signal.
Principle:
Current flowing through the coil of the relay creates a magnetic field which attracts a lever and changes the switch contacts. The coil current can be on or off so relays have two switch positions and most have double throw (changeover) switch contacts.Program:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <LPC214X.H> | |
#define R1 0x00000010 | |
#define R2 0x00000020 | |
//*************************************** | |
void delay(int z) | |
{ | |
int x,y; | |
z=z*5; | |
for(x=0;x<=2400;x++) | |
{ | |
for(y=0;y<=z;y++); | |
} | |
} | |
//***************************************************** | |
int main(void) | |
{ | |
IODIR0=0x00000030; | |
IOCLR0=0x00000030; | |
while(1) | |
{ | |
IOSET0=R1; | |
IOCLR0=R2; | |
delay(1000); | |
IOSET0=R2; | |
IOCLR0=R1; | |
delay(1000); | |
} | |
} |
Comments
Post a Comment