PIC16F84A 7-Segment Display Example – 4-Digit Digital Counter

Interfacing PIC16F84A microcontroller with 7-segment display

This topic shows how to build a digital counter that counts from 0 to 9999 using PIC16F84A microcontroller and CCS PIC C compiler. The 4-digit 7-segment display uses multiplexing technique which means all the data lines from a to g are connected together for all the four digits. We will see circuit and code for both types of the 7-segment display: common anode and common cathode.
The following video shows a hardware circuit of the digital counter:

Hardware Required:

  • PIC16F84A microcontroller   —> datasheet
  • 8MHz crystal oscillator
  • 2 x 22pF ceramic capacitor
  • Common anode/common cathode 4-digit seven-segment display module
  • 4 x 2N3906 PNP transistor
  • Push button
  • 10k ohm resistor
  • 4 x 4.7k ohm resistor
  • 4 x 1k ohm resistor
  • 7 x 100 ohm resistor
  • 5V power source
  • Bread board and jumper wires
  • PIC microcontroller programmer (PICkit 2, PICkit 3…)

Interface PIC16F84A with common anode 7-segment display:
In common anode 7-segment display type all the 7 LED’s anodes are connected together.
Interfacing PIC16F84A with common anode 7-segment display (digital counter circuit) circuit schematic is below.
PIC16F84A 7-segment display common anode circuit
If the button which is connected to RB7 pressed the displayed number will be incremented by 1. The PIC16F84A microcontroller must be supplied with +5V between its power pins VDD (#14) and VSS (#5) (not shown in the circuit diagram).

4-Digit common anode 7-segment display counter with PIC16F84A CCS C code:

Interface PIC16F84A with common cathode 7-segment display:
In common cathode 7-segment display type all the 7 LED’s cathodes are connected together.
The following circuit schematic is for 4-digit digital counter counts from 0 to 9999, the number is incremented when button is pressed.
PIC16F84A 7-segment display common cathode circuit
The PIC16F84A microcontroller must be supplied with +5V between its power pins VDD (#14) and VSS (#5) (not shown in the circuit diagram).

4-Digit common cathode 7-segment display counter interfacing with PIC16F84A CCS C code:

Leave a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top