echo '' ;

8051 Interface – 7 Segment Display

This tutorial will discuss about 8051 Interface – 7 Segment Display. 7-Seg display is the most basic electronic display. It consists of eight LEDs which are associated in a sequence manner to display digits from 0 to 9 when proper combinations of LEDs are switched on. A 7-segment display uses seven LEDs to display digits from 0 to 9 and the 8th LED is used for dot. A typical seven-segment look likes as shown in the figure below. The 7-segment displays are used in several systems to display the numeric information. They can display one digit at a time. Thus the number of segments used depends on the number of digits to display. Here the digits 0 to 9 are displayed continuously at a predefined time delay.

Read more: 8051 Interface – 7 Segment Display
7-Segment Display

The 7-segment displays are available in two configurations which are common anode (V+) and common cathode (GND). Here, we use the common anode configuration because the output current of the microcontroller is not sufficient to drive the LEDs. The 7-segment display works on negative logic, we have to provide logic 0 to the corresponding pin to make on LED glow. In this tutorial, you can learn 8051 interfaces 7 segment display with 8051 controller. I chose the AT89S51 micro controller(You can select any other Keil support microcontroller) and demonstrated, that this is very simple and follow this below.

The following table shows the hex values used to display the different digits.

Use of 7 Segment Display

  • Numeric Display: Shows numbers (0-9) and some letters (A-F).
  • Segment Control: Each segment can individually controlled.
  • Connection: Requires connection to microcontroller GPIO pins.
  • Display Logic: Determine which segments to illuminate for each digit.
  • Multiplexing: Can display multiple digits by rapidly switching between them.
  • Example Usage: Digital clocks, timers, counters, and temperature displays.

Required software

Required components and Programmer

  • 1x AT89S51 Controller
  • 1x 4Mhz Crystal
  • 2x 22pf capacitor
  • ISP AVR USB programmer
  • 7 Seg Display

Circuit Diagram

C code

#include<reg51.h>

void delay(int k) //delay function
{
int i,j;
for(i=0;i<k;i++)
  for(j=0;j<1275;j++);
}
void main()
{
    unsigned char i;
    unsigned char arr[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x67};
    P2=0x00;    
    while(1)
    {
        for(i=0;i<10;i++)
        {
            P2=arr[i];
            delay(100);
        }
        
    }
}

Assembly Code (ASM)

//See more on : http://www.ArunEworld.com

ORG 000H //initial starting address
START: MOV A,#00001001B // initial value of accumulator
MOV B,A
MOV R0,#0AH //Register R0 initialized as counter which counts from 10 to 0
LABEL: MOV A,B
INC A
MOV B,A
MOVC A,@A+PC // adds the byte in A to the program counters address
MOV P1,A
ACALL DELAY // calls the delay of the timer
DEC R0//Counter R0 decremented by 1
MOV A,R0 // R0 moved to accumulator to check if it is zero in next instruction.
JZ START //Checks accumulator for zero and jumps to START. Done to check if counting has been finished.
SJMP LABEL
DB 3FH // digit drive pattern for 0
DB 06H // digit drive pattern for 1
DB 5BH // digit drive pattern for 2
DB 4FH // digit drive pattern for 3
DB 66H // digit drive pattern for 4
DB 6DH // digit drive pattern for 5
DB 7DH // digit drive pattern for 6
DB 07H // digit drive pattern for 7
DB 7FH // digit drive pattern for 8
DB 6FH // digit drive pattern for 9
DELAY: MOV R4,#05H // subroutine for delay
WAIT1: MOV R3,#00H
WAIT2: MOV R2,#00H
WAIT3: DJNZ R2,WAIT3
DJNZ R3,WAIT2
DJNZ R4,WAIT1
RET
END

NEXT

8051 – Introduction
8051 – Program Methods
8051 – Flash HEX into 8051
8051 – USB ISP Programmer
8051 – Simulators
8051 Interface
8051 Interface – LED
8051 Interface – LCD
8051 Interface – 7 Segment
8051 Interface – Keypad
8051 Interface – Servo
8051 Protocol Interface
8051 – UART Bit banking
8051 – I2C Bit banking (Add Soon)
8051 Tutorials
8051 – 10Khz Square Wave
Others
8051 – Interview Questions

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from ArunEworld

Subscribe now to keep reading and get access to the full archive.

Continue reading