0% found this document useful (0 votes)
34 views

LED Control with 8051 Assembly Code

The document explains an experiment using the 8051 microcontroller to control an LED through assembly language, focusing on toggling a port pin and implementing a delay for a blinking effect. The program initializes Port 1, uses CLR and SETB instructions to turn the LED on and off, and employs a delay subroutine with nested loops for timing. The successful execution of the program demonstrated fundamental principles of microcontroller-based LED control and port manipulation.

Uploaded by

K R I S T
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

LED Control with 8051 Assembly Code

The document explains an experiment using the 8051 microcontroller to control an LED through assembly language, focusing on toggling a port pin and implementing a delay for a blinking effect. The program initializes Port 1, uses CLR and SETB instructions to turn the LED on and off, and employs a delay subroutine with nested loops for timing. The successful execution of the program demonstrated fundamental principles of microcontroller-based LED control and port manipulation.

Uploaded by

K R I S T
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Code Explanation

Breakdown of the MAIN Section


The MAIN section of the assembly code begins with the initialization of Port 1, setting it to high. This
is achieved with the instruction:
MOV P1, #0FFH

This command configures all pins of Port 1 as outputs by assigning a logic high (1) to them.
Next, the infinite loop is initiated:
MAIN:
CLR P1.0
; Delay subroutine call
SETB P1.0
; Delay subroutine call
SJMP MAIN

1. CLR P1.0: This instruction clears bit 0 of Port 1, turning the LED on if it is connected to P1.0.
2. SETB P1.0: This sets bit 0 of Port 1 back to high, turning the LED off.
After each toggling operation, the code calls a DELAY subroutine, ensuring that the LED remains in
each state long enough to be visually perceived.

DELAY Subroutine
The DELAY subroutine is critical for creating the timing necessary for the LED blinking effect. It
employs nested loops as follows:
DELAY:
MOV R0, #255
DELAY1:
MOV R1, #255
DELAY2:
DJNZ R1, DELAY2
DJNZ R0, DELAY1
RET

• MOV R0, #255 and MOV R1, #255: These lines initialize registers R0 and R1 with a count of
255, establishing the loop iterations.
• DJNZ R1, DELAY2: This decrements R1 and checks if it is zero; if not, it loops back to
DELAY2.
• DJNZ R0, DELAY1: Similar to R1, but for R0, it controls the outer loop.
Experiment Report Summary: Blinking LED using 8051 Microcontroller
This experiment aimed to demonstrate the control of an LED using the 8051 microcontroller through an
assembly language program. The primary objective was to implement a simple LED blinking circuit by
toggling a port pin and incorporating a delay loop to create a visible blinking effect. The experiment
utilized an 8051 microcontroller, Keil uVision or an 8051 assembler, an LED, a resistor, a power supply,
and connecting wires.
The program was written in assembly language, with Port 1 (P1) used to control the LED. The code began
by setting all bits of Port 1 high, followed by toggling P1.0 using CLR and SETB instructions to turn the
LED ON and OFF. A delay subroutine, implemented using nested loops with registers R1 and R2, created
the necessary time delay for the blinking effect. The program ran in an infinite loop, ensuring continuous
blinking.
The procedure involved writing and compiling the code in Keil uVision, loading the HEX file into the
microcontroller, and connecting the LED to P1.0 with a current-limiting resistor. Upon powering the
circuit, the LED blinked at regular intervals, confirming the successful execution of the program.
Observations highlighted the effectiveness of the delay subroutine and the precise control of the LED
state using SETB and CLR instructions.
In conclusion, the experiment successfully demonstrated the fundamental principles of microcontroller-
based LED control. The use of assembly language and delay loops provided a clear understanding of port
manipulation and timing in embedded systems, laying the groundwork for more advanced applications in
microcontroller programming.
Experiment Report Summary: Blinking LED using 8051 Microcontroller (Roman Konkani)
Ha experiment 8051 microcontroller vaprun ek LED control korpache sodun dakhoitalo. Mukhel uddes
asa ek simple LED blinking circuit tayar korunk, jicho kaam ek port pin toggle korunk ani ek delay loop
vaprun visible blinking effect create korunk.
Experimentant 8051 microcontroller, Keil uVision vo 8051 assembler, ek LED, ek resistor, power supply
ani connecting wires vaprlele.
Program assembly languageant likhle, j’mmant Port 1 (P1) LED control korpak vaprlo. Code suru zale ani
Port 1-chem sogle bits high kelam. P1.0 toggle korpak CLR ani SETB instructions vaprle, LED ON ani OFF
korunk. Ek delay subroutine nested loops (registers R1 ani R2 vaprun) modify kele, jenne blinking effect
utpnno zale. Hya programan ek infinite loopant challim, jenne LED lagatar blink zatalo.
Procedureant, code Keil uVisionant liyon compile kelam, HEX file microcontrollerant load kelam, ani LED
P1.0-la ek current-limiting resistor sangtlo. Circuit power zalea uprant, LED thod-thod intervalant blink
zalem, j’mmant experiment successful zalo. Observationsant delay subroutinechi effectiveness ani SETB-
CLR instructions vaprun LED control korpak zalele precise method sodun dakhoilo.
Ek zoddet, hya experimentan microcontroller-based LED controlchem mukhel principles successful
dakhoilem. Assembly language ani delay loops vaprun port manipulation ani timing kosso kam korta te
sodun dakhoilem, jenne microcontroller programmingant advanced applications korpache ek bhitor
tayar zale.

You might also like