Wednesday 18 February 2015

Interfacing of led with 8051

Led (  Light emitting diode) : Light Emitting Diodes are the mostly commonly used components in many applications. They are made of semiconducting material. This article describes about basic interfacing of LEDs to the 8051 family microcontrollers.


Circuit diagram for blinking a led:


How to Operate LED Interfacing with 8051 Microcontroller Circuit:

  • Initially, burn the code into the microcontroller.
  • Now, connect the LEDs to the port of the microcontroller.
  • Switch on the circuit.
  • Thus one can observe LEDs glowing.
  • Now, switch off the circuit.
Program for blinking a led:

1) ASM code:

$mod51
org 00h
back:
setb p1.0
clr p1.1
sjmp back
end

2) C code:

#include<reg51.h>
sbit  led =P1^0;

void main()
{
      while(1)
         {
              led=1;
              led=0;
          }
}


3) Proteus Simulation:





Program to switch on and off an 8 Leds connected at P1

1) ASM code:

$mod51
org 00h
back:
mov p1,#0ffh
mov p1,#00h
sjmp back
end

2) C code:

#include<reg51.h>
void main()
{
      while(1)
         {
            P1=0XFF;
            P1=0X00;
          }
}


3) Proteus Simulation:






Program to switch on and off an 8 leds connected at port1 with 1 sec delay:


1) ASM code:

$mod51
org 00h
back:
mov p1,#0ffh
acall delay
mov p1,#00h
acall delay
sjmp back
delay:
mov r4, #255
L4: mov r5,#255
L5: mov r6,#10
L6: djnz r6,L6
    djnz r5,L5
    djnz r4,L4
ret

end

2) C code:

#include<reg51.h>

void delay()
{   int x,y;
     for(x=0;x<=1000;x++)
       {
             for(y=0;y<=1275;y++);
       }
}

void main()
{
      while(1)
         {
            P1=0XFF;
            delay();
            P1=0X00;
            delay();
          }
}


3) Proteus simulation:




























0 comments:

Post a Comment

if you have any doubt please let me know