A 7 Segment 2 Digits Display with microC and Proteus on pic16f877.

7 segment display 2


In this tutorial, we will learn how to use a dual 7 segment display with the pic16f877. For this we will use the software tools and hardware components necessary to create a 7-segment display. In fact, the main ones being a 7 segment 2 digit display, a PIC microcontroller, then the MicroC application for writing the code and finally Proteus for simulation.

List of components.

  • 1 7-segment 2-digit display.
  • 1 PIC microcontroller 16f877.
  • 4 push buttons: 1 for starting, 1 for pause, 1 for stopping and the other for setting to 0.
  • 2 capacitors.
  • a Quartz Crystal.
  • 4 resistors.

What is a 7 segment display?

Defined in the simplest way, a 7-segment display module is a display made up of 7 LEDs. These LEDs are mounted so as to obtain the numbers going from 0 to 9 and the letters from A to F. It is therefore in assembly of LEDs positioned so as to form according to the combination given, the figures and numbers of the base hexa.

Different types of 7-segment display.

Depending on their design, 7-segment displays are divided into two main types. Thus, we will have 7-segment displays with a common anode and 7-segment displays with a common cathode.

The 7-segment display with common cathode.

On the 7-segment common cathode display, the LEDs have
cathodes connected. So for lighting a segment of LED we will use the 1 logic.

7-segment display with common anode.

In the case of a 7-segment display with a common anode, the LEDs have anodes connected to each other. Thus, for lighting a segment of LED we will use the logic state .

Assembly diagram of our 7-segment display.

7-segment display operating principle.

To display a number on a 7-segment display, simply turn on the corresponding LEDs. Thus, each digit has a hexadecimal or binary code depending on the type of display. For example, codes from 0 to 9
for a common anode display.

Are: {0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90}

Use of a 7-segment display.

Frequently, 7-segment displays are used in watches, radios, calculators, etc. In practice, they are found in most of our household appliances such as hobs, electric ovens, microwaves and more. Likewise, we also find them in the industrial environment and in particular on vehicles, welding stations and many others.

To know

Arduino Project: How to Download and Install Arduino


For our example we will display on our 7 two-digit segment display the numbers 0 to 10.

Creation of a 7-segment display on pic16f877 with proteus and microC.

7-segment display program written with microC.

//declaration des variables.
    int i,j,k=0;
    int cont=0;
    int T[10]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90};
    //fonction principale
 void main() {
 //configuration des port
while(1){    // boucle infini
 if(portb.f0==1 && portb.f3==0){  // condition d'activation du comptage

        j=i/10;            //chiffre des unit├ęs
        k=i%10;                //chiffre des dizaines
        while( cont<100){
         PORTc.f0=1;    //activation du premier digit
       delay_ms(10);   //attente de 10 ms
        PORTc.f0=0;  //desactivation du premier digit

        PORTc.f1=0;  //desactivation du second digit
         if(portb.f1==1) goto rec;      //condition de remise a 0
         if(portb.f1==1 && portb.f0==1 ) goto rec;   //condition de remise a 0
         if(portb.f2==1 && portb.f1==0   ) goto pause;   //condition de remise a pause le comptage
          if(portb.f2==1 && portb.f0==1 && portb.f1==0  ) goto pause;  //condition de remise a pause le comptage

Conclusion on the creation of a 7 segment 2 digit display.

The operating principle of 7-segment displays is the same regardless of their configuration. Which makes their implementation simpler.

You May Also Like

Leave a Reply

Your email address will not be published. Required fields are marked *