Interfacing Seven Segment with 8051

7 Segment LED Display:





Image result for 7 segment display gif

Hardware connection:

 
7seg LED display with 8051
7seg LED display with 8051

Program:



1st method:


#include <reg52.h>
void Delay(unsigned int ms_Count)
{
    unsigned int i,j;
    for(i=0; i<ms_Count; i++)
    {
        for(j=0; j<100; j++);
    }
}


int main()
{
    P1 = 0x00;
   
    while(1)
    {
        P1 = 0x06;                //Display 1
        Delay(1000);
        P1= 0x5B;                //Display 2
        Delay(1000);
        P1 = 0x4F;                //Display 3
        Delay(1000);
    }        
}


2nd Method:




#include <reg51.h>

void delay(unsigned int k)
{
    unsigned int i,j;
    for(i=0;i<k;i++)
    {
        for(j=0;j<100;j++);
    }
}

int main() {
    char seg_code[]={0x06,0x5b,0x4f};   
    int i;

    while (1)
    {
        for (i = 0; i <= 2; i++)        // loop to display 1-3
        {
            P1 = seg_code[i];
            delay(1000);
        }
    }
}



 If you have any doubts do comment, thank you.



Related Posts:

  • Keil Setup For 8051 In this tutorial we see how to setup Keil4 for generating .hex file.Keil software can be downloaded from this link.Download and install the Keil C51 for 8051. Keil Setup Steps Step1: Open the Keil software and… Read More
  • Microcontrollers - 8051 Pin Description The pin diagram of 8051 microcontroller looks as follows − Pins 1 to 8 − These pins are known as Port 1. This port doesn’t serve any other functions. It is internally pulled up, bi-directional I/O port. Pin 9 … Read More
  • Microcontrollers 8051 Input Output Ports 8051 microcontrollers have 4 I/O ports each of 8-bit, which can be configured as input or output. Hence, total 32 input/output pins allow the microcontroller to be connected with the peripheral devices. Pin configuration,… Read More
  • Microcontrollers - 8051 Architecture 8051 microcontroller is designed by Intel in 1981. It is an 8-bit microcontroller. It is built with 40 pins DIP (dual inline package), 4kb of ROM storage and 128 bytes of RAM storage, 2 16-bit timers. It consists of are fou… Read More
  • Microcontrollers - 8051 Interrupts Interrupts are the events that temporarily suspend the main program, pass the control to the external sources and execute their task. It then passes the control to the main program where it had left off. 8051 has 5 interru… Read More