Multiplexing seven segment display use PIC Microcontroller and Mikro C
In this tutorial we will learn how multiplexing 7 segment display whit microcontroller. Here I am use PIC16F877A micrcorontroller and 3 digit seven segment display.
You can watch the following video or read the written tutorial below.
7 segment display
seven segment display has 7 segment and each segment emit light. When segment a,b,c,d,e & f emit light than the display show the decimal value 0.
3 digit 7 segment display
![]() |
0.56'' - digit size |
Circuit Diagram
Mikro C Code for Common Cathod:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Common Cathod display | |
unsigned int display[10] = {0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F}; | |
char i; | |
char digit1,digit2,digit3; | |
void main() { | |
TRISB = 0X00; // PORTB is output | |
PORTB = 0X00; // Clear PORTB | |
TRISC = 0X00; // PORTB is output | |
PORTC = 0X00; // Clear PORTB | |
i=101; // 7seg show the 101 | |
while(1){ // Endless loop | |
digit1 = (i/100); | |
PORTB = display[digit1]; // MSB digit1 | |
PORTC = 0X01; | |
delay_ms(5); // 5ms delay | |
PORTC =0X00; | |
digit2 = (i/10)%10; | |
PORTB = display[digit2]; | |
PORTC = 0X02; | |
delay_ms(5); | |
PORTC = 0X00; | |
digit3 = i%10; | |
PORTB = display[digit3]; | |
PORTC = 0X04; | |
delay_ms(5); | |
PORTC =0X00; | |
} | |
} |
Click the Download button for source code:
![]() |
download |
No comments