LED Interfacing With 8051

by embeddedbymedhavi in Circuits > Microcontrollers

437 Views, 0 Favorites, 0 Comments

LED Interfacing With 8051

led pin.jpg

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.

LED Interfacing With 8051

led circuit.jpg

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:

l1.png

1) ASM code:

$mod51

org 00h

back: setb p1.0

clr p1.1

sjmp back

end

2) C code:

#include sbit led =P1^0;

void main() {

while(1)

{

led=1;

led=0;

} }

3) Proteus Simulation:

Circuit is given above


Program to Switch on and Off an 8 Leds Connected at P1

l2.png

1) ASM code:

$mod51

org 00h

back:

mov p1,#0ffh

mov p1,#00h

sjmp back

end

2) C code:

#include

void main()

{

while(1)

{

P1=0XFF;

P1=0X00;

} }

3) Proteus Simulation:

Circuit is given above.

Program to Switch on and Off an 8 Leds Connected at Port1 With 1 Sec Delay:

l3.png

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

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:

Circuit is given above.

Video of LED Interfacing With 8051

Interfacing of Led with 8051 Microcontroller

Any Query related Embedded System , IOT and Raspberry PI go to My Blog:

embeddedbymedhavi