fbpx

Interface Relay With AVR

Description

Relay is an electrically operated switch. Relay is used to isolate electrical load.

  • Two configuration
    1.NO(normally open).
    2.NC(normally close).
  • Relay has a coil which is energized by 12v when coil energized switching action takes place.

BC548

  • BC548 is general purpose NPN bipolar junction transistor.
  • This transistor act as a driver to pull the relay ON.
  • The base is connected with a micro-controller in series with the resister.
  • Emitter to ground.
  • Collector to relay.

Hardware Required

  • Relay.
  • BC548 Transistor.
  • Atmega16 MicroController.

Circuit

Virtual Circuit

Code

 #include <avr/io.h>
 #include <util/delay.h>
 int main(void)
 {
 DDRA= 0x01;
 DDRC= 0x00;
 PORTA=0X00;
 PORTC=0X00;
 while(1)
 {
 int a= PINC;
 if(a == 0 )
 {
 PORTA=0x01;
 }
 else
 {
 PORTA=0x00;
 }
 }
 } 

Leave a Reply

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