Sunday, 16 September 2012

HOW TO BLINK AN LED USING 8051 include keil(c and hex(.a51)) and Proteus

Design circuit diagram in Proteus as bellow :-


put all component as shown in figure.


Program To Blink an led in Assembly Language

org 0000h
mov P2,#00h        ; initialize the Port2 as output port
top: cpl P2.0         ; compliment the bit
acall delay             ; call delay procedure
sjmp top               ; make this operation to run repeatedly

delay:
mov R1,#010h     ; initialize the R1 register with an immediate value 10h = 16d
mov R0,#0FFh     ; load R0 with FFh value to repeat the loop for 256 times
back: DJNZ R0    , back ;internal loop repeates 256 times
DJNZ R1,back     ;external loop repeates 16 times
RET
End



Program To Blink an led in c

#include
sbit LED = P2^0;            // define Port2 pin as an LED
void delay(int);

void main()
{
while(1)                         // infinite loop
{
LED = ~LED;              // toggle LED
delay(10000);
}                                 // end of while loop


}                                // end of main

void delay(int i)
{
for(;i>0;i--);
}

No comments:

Post a Comment

must read

NOTE:-we don't make all projects, all are of from different website.we also don't know where they have taken from.we just helping student and needed people .we are don't responsible for any harm from our website.thank you.