The document provides assembly language programs for interfacing LEDs and seven-segment displays with the 8051 microcontroller. It includes a program for blinking LEDs and another for displaying digits and the word 'HELLO' on a seven-segment display. It also explains the differences between common cathode and common anode types of seven-segment displays.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
30 views9 pages
LED and Its Interfacing With 8051 Microcontroller
The document provides assembly language programs for interfacing LEDs and seven-segment displays with the 8051 microcontroller. It includes a program for blinking LEDs and another for displaying digits and the word 'HELLO' on a seven-segment display. It also explains the differences between common cathode and common anode types of seven-segment displays.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9
Module:5
INTERFACING WITH 8051
LED INTERFACING WITH 8051 PROGRAM FOR BLINKING OF LEDS ORG 00H ; Assembly Starts from 0000H. START: MOV P1, #0FFH ; Move 11111111 to PORT1. ACALL WAIT ; Call WAIT MOV A, P1 ; Move P1 value to ACC CPL A ; Complement ACC MOV P1, A ; Move ACC value to P1 ACALL WAIT ; Call WAIT SJMP START ; Jump to START WAIT: MOV R2, #10 ; Load Register R2 with 10 (0x0A) WAIT1 MOV R3, #200 ; Load Register R3 with 10 (0xC8) : MOV R4, #200 ; Load Register R4 with 10 (0xC8) WAIT2 DJNZ R4, WAIT3 ; Decrement R4 till it is 0. Stay there if not 0. : DJNZ R3, ; Decrement R3 till it is 0. Jump to WAIT2 if not 0. WAIT3 WAIT2 DJNZ ; Decrement R2 till it is 0. Jump to WAIT1 if not 0. : R2, WAIT1 RET ; Return to Main Program END ; End Assembly SEVEN SEGMENT DISPLAY • 7 segment LED display is very popular and it can display digits from 0 to 9 and quite a few characters like A, b, C, ., H, E, e, F, n, o, t, u, y, etc. • A seven segment display consists of seven LEDs arranged in the form of a squarish ‘8’ slightly inclined to the right and a single LED as the dot character. • Different characters can be displayed by selectively glowing the required LED segments. • Seven segment displays are of two types, common cathode and common anode. • In common cathode type, the cathode of all LEDs are tied together to a single terminal which is usually labeled as ‘com‘. • In common anode type, the anode of all LEDs are tied together as a single terminal and cathodes are left alone as individual pins. SEVEN SEGMENT DISPLAY INTERFACING
• Since these are basically LEDs arranged as a group they can
either have the anode in common or cathode thus they are named as Common-Anode/Common-Cathode displays.
• Common Cathode: In this type of segments all the cathode
terminals are made common and tied to GND. Thus the segments a to g needs a logic High signal(5v) in order to glow.
• Common Anode: In this type of segments all the anodes
terminals are made common and tied to VCC(5v). Thus the segments a to g needs a logic LOW signal(GND) in order to glow. Assembly language program to interface seven segment display (0-9) when it connected to port1 ORG 0000H MAIN: MOV DPTR, #400H REPEAT: CLR A MOVC A, @A+DPTR ; Copy data from external location to accumulator MOV P1, A ; Move the pattern of the digit into port P1 ACALL DELAY ; Call a delay to so that the transition is visible INC DPTR ; Point to the next pattern CJNE A, 0, ; Repeat till 0 (Stop bit) is received REPEAT ; Run this forever till externally stopped SJMP MAIN DELAY: MOV R0, LP2: MOV #08H R1, #0FFH MOV R2, LP1: #0FFH DJNZ R2, LP3 DJNZ R1, LP1 LP3: DJNZ R0, LP2 RET ORG 400H DB 3FH, 06H, 5BH, 4FH, 66H, 6DH, 7DH, 07H, 7FH, 6FH, ; Lookup table for digits 0 to 9 END Write a program to display “HELLO” by using seven segment display while it is connected to port 0 of 8051. ORG 0000H MAIN: MOV DPTR, #200H MOV R0,#05H REPEAT: CLR A MOVC A, ; Copy data from external location to accumulator @A+DPTR MOV P0, ; Move the pattern of the digit into port 0 A ; Call a delay to so that the transition is visible ACALL DELAY ; Point to the next pattern INC DPTR ; Repeat till R0 = 0 DJNZ R0, REPEAT ; Run this forever till externally stopped SJMP MAIN DELAY: MOV R0, #08H LP2: MOV R1, #0FFH MOV LP1: R2, #0FFH DJNZ R1,R2, DJNZ LP1LP3 LP3: DJNZ R0, LP2 RET
ORG 200H DB 76H, 79H, 38H, 38H, 3FH ; Lookup table for alphabets