We are very familiar with “Hello world!” basic program code in the initial stage of any programming language to learn some basic things. Similarly to get started with any Microcontroller, LED interfacing is a basic and simplest experiment to see a physical output..
Each Microcontroller is different in its architecture, but the interfacing concepts are almost same for all. One can understand the concept of input-output configurations of the general-purpose I/O port in a microcontroller with the simple LED blinking project. This tutorial will explain the method of interfacing LEDs with 8051 microcontrollers.
ORG 00H ; PROGRAM STORE LOCATION
MOV P0,#00H ; REFRESHING PORT-0
MOV P1,#00H ; REFRESHING PORT-1
MOV P2,#00H ; REFRESHING PORT-2
MOV P3,#00H ; REFRESHING PORT-3
AGAIN:
CLR P0.7 ; PORT-0 PIN-7 LOW (LED1-ON)
SETB P2.0 ; PORT-2 PIN-0 HIGH (LED2-ON)
LCALL DELAY ; CALL DELAY SUBROUTINE
SETB P0.7 ; PORT-0 PIN-7 HIGH (LED1-OFF)
CLR P2.0 ; PORT-2 PIN-0 LOW (LED2-OFF)
LCALL DELAY ; CALL DELAY SUBROUTINE
LJMP AGAIN ; LOOP FOREVER TO LABEL AGAIN
DELAY: ; DELAY SUBROUTINE
MOV R7,#50
L3 : MOV R6,#100
L2 : MOV R5,#100
L1 : DJNZ R5,L1
DJNZ R6,L2
DJNZ R7,L3
RET ; END DELAY SUBROUTINE
END