Binary/bcd to 7-segment decoder for PIC16F627A


This is a building block project I developed to try out a few ideas.  It decodes a 4-bit binary word to outputs that will drive a 7-segment LED display.  Functionality is similar to the 7447 BCD-to-seven-segment decoder/driver IC however, because it’s implemented using a microcontroller, the segment control data can be customised to display any set of 16 characters you wish to create.  It also has an ‘invert’ control input that allows it to drive either common anode (active low) or common cathode (active high) LED modules.

7-segment decoder

Binary or BCD to 7-segment decoder

  • 4-bit binary input to 7-segment decode, 0-9, A-F
  • Lamp test input
  • Zero blanking
  • output invert, allows use of common anode or common cathode displays
  • input latch
  • Outputs rated at 20mA per segment (Max)

Demo / evaluation schematic

The idea behind this project is that the PIC can be used as a decoder for 7-segment LED displays and therefore it will be built into some other application.  The schematic is provided for evaluation only.



The PIC use an internal clock source so no external timing components are required, you will need to fit a decoupling capacitor across the Vdd/Vss supply close to the PIC; 100nF ceramic will do the job..

Inputs require an external pull-up resistor unless actively driven by an external source. All unused inputs should be tied to Vdd via a 4K7 resistors.

Because the decoder is implemented in software running on the PIC, input to output propagation delays are 15uS.  Input data on A0-A3 should be held for 15uS after en/latch input goes high to ensure input is latched.

Outputs on the PIC16F627A / 628A are rated at 25mA with a maximum of 200mA for all I/O pins.  This means it can drive a 7-segment LED display directly (via current limit resistors).

Customizing Segment Data

The segment data used to drive the outputs is held in the EEPROM of the PIC making it easy to edit without having to reassemble the source code.

The data is held at addresses 00 to 0F in the format shown below


For more detail: Binary/bcd to 7-segment decoder  for PIC16F627A

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us: