Header Ads

How to Interfacing seven segment display with pic microcontroller (decrease value)

In this tutorials I am show how to interface a seven segment display whit pic microcontroller. You can watch the flowing video and read the written tutorial below.





7 segment displays are two type . they are liquid crystal and light emitting diode. In this this tutorials I am used light emitting seven segment display. 7 segment display contain 7 LED of a digit. When LED is  active and it emit light. In this tutorial we are used common cathode 7 segment display.




Internal structure of seven segment display below



7 segment display are used in digital clocks,electronics meter,measuring tools,calculator and electronics elements. It show decimal value from binary value.









CIRCUIT DIAGRAM

   

Code Explain:
Here I am use Mikro C compiler for code editing. In define section we define a array for common cathode display. The display show the value in decimal numbers. Then in void main function we define PORTB is output by clearing TRISB register. Than we clear the PORTB by clearing PORTB register. Next we create a while loop for continues program execution. In while loop function we create a for loop. The for loop increase the value of i variable. The value of i is increase 0 to 9 and show the value on 7 segment display.

Mikro C Code:

unsigned int display[10] = {0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};

int x;           //x is integer data type

void main() {

     TRISB = 0X00;

     PORTB = 0X00;

     while(1){

              for(x=9;x>=0;x--){

                                PORTB = display[x];

                                delay_ms(500);

                                }

               PORTB = 0X00;

              

              }

                               

}


Click the download button for source code:
download

No comments

Theme images by 5ugarless. Powered by Blogger.