Sie sind auf Seite 1von 3

Experiment No.

:- 5

Aim :-Develop a program to Blink LED for 1Second

Apparatus:- keiluvision5 software

Theory :-

Light Emitting Diodes or LEDs are the mostly commonly used components in many applications.
They are made of semiconducting material. In this project, I will describe about basics of
Interfacing LED with 8051 Microcontroller.

Principle behind Interfacing LED with 8051

The main principle of this circuit is to interface LEDs to the 8051 family micro controller.
Commonly, used LEDs will have voltage drop of 1.7v and current of 10mA to glow at full
intensity. This is applied through the output pin of the micro controller.

Circuit Diagram
The circuit mainly consists of AT89C51 microcontroller. AT89C51 belongs to the family of 8051
microcontroller. It is an 8-bit microcontroller. This microcontroller has 4KB of Flash
Programmable and Erasable Read Only Memory and 128 bytes of RAM. This can be programmed
and erased a maximum of 1000 times.

It has two 16 bit timers/counters. It supports USART communication protocol. It has 40 pins.
There are four ports are designated as P0, P1, P2, and P3. Port P0 will not have internal pull- ups,
while the other ports have internal pull-ups.

In this circuit, LEDs are connected to the port P0. The controller is connected with external crystal
oscillator to pin 18 and 19 pins. Crystal pins are connected to the ground through capacitors of
33pf.

Code:-
Crystal Frequency = 12MHz / 12 Machine Cycles = 1Mhz

;1/1MHz = 1 Microsecond

;(250 x 250 x 2 x 1Microsecond) x 8 times ACALL Delay = 1 Second

ORG 0000H
SETB P1.0 ;Set Port Bit 0 of P1 to HIGH
BACK: ACALL DELAY ;WAIT 0.125 Second
ACALL DELAY ;WAIT 0.125 Second
ACALL DELAY ;WAIT 0.125 Second
ACALL DELAY ;WAIT 0.125 Second
ACALL DELAY ;WAIT 0.125 Second
ACALL DELAY ;WAIT 0.125 Second
ACALL DELAY ;WAIT 0.125 Second
ACALL DELAY ;WAIT 0.125 Second

CPL P1.0 ;Complement Bit 0 of Port 1,High-to-Low


SJMP BACK ;Make This Operation to Run Repeatedly

DELAY:MOV R0,#250 ;Initialize the R0 Register With an Immediate Value 250


NEXT: MOV R1,#250 ;Load R0 With 250 Value to Repeat the Loop for 250 Times

AGAIN:DJNZ R1,AGAIN ;Internal Loop Repeates 250 Times


DJNZ R0,NEXT ;External Loop Repeates 250 Times
RET ;Return to Caller
END ;End of .asm File
Expected output:-

Das könnte Ihnen auch gefallen