Make Counter use seven segment display and PIC Microcontroller
In this tutorial we will learn how to make counter use 7 segment display use PIC 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
Circuit Diagram
Mikro C Code:
Click the download button for source code :
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:
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 | |
# define SW1 PORTC.RC0 | |
# define SW2 PORTC.RC1 | |
char display[10] = {0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F}; | |
int i = 0; | |
char digit1,digit2,digit3; | |
void main() { | |
TRISB = 0X00; | |
TRISD = 0X00; | |
PORTB = 0X00; | |
PORTD = 0X00; | |
while(1){ | |
if(SW1==1){ | |
//while(SW1==1); | |
i++; | |
delay_ms(250); | |
} | |
if(SW2==1){ | |
//while(SW2==1); | |
i--; | |
delay_ms(250); | |
} | |
if(i==1000) i ==0; | |
if(i==-1) i =0; | |
digit1 = i/100; | |
digit2 = (i/10)%10; | |
digit3 = i%10; | |
PORTB = display[digit1]; | |
PORTD = 0X01; | |
delay_ms(5); | |
PORTD = 0X00; | |
PORTB = display[digit2]; | |
PORTD = 0X02; | |
delay_ms(5); | |
PORTD = 0X00; | |
PORTB = display[digit3]; | |
PORTD = 0X04; | |
delay_ms(5); | |
PORTD = 0X00; | |
} | |
} |
Click the download button for source code :
![]() |
download |
No comments