Built in 2019
PIC 16F84A Matrix 5x7
PIC 16F84A Matrix Display
PIC 16F84A programmed to show names in a 5x7 matrix implemented as a Computer Architecture course project.
Made with
A 5x7 matrix has 35 LEDs. Controlling each one on its own would need 35 output pins. The PIC 16F84A has 13. The math does not work, unless you cheat with multiplexing.
I found this out in my Computer Architecture course. I needed a project that showed low level hardware control. A 5x7 LED matrix that shows names seemed simple enough. Then I started counting the pins.
You see LED matrix displays on scoreboards, in train stations and on advertising signs. From the outside, they look easy. You light up some dots and they form letters. Lighting the right dots at the right time takes precise timing and a few hardware tricks.
Two names on loop
The project shows two names on the matrix. First “MENDEZ”, then “ANDRADE”, then decorative star patterns. Each letter stays for about half a second before the display moves to the next character. The sequence loops forever.
The display depends on persistence of vision. Your eye keeps an image for a moment after the light is gone. The microcontroller lights one column at a time. It cycles through all five columns so fast that you see a complete letter. Each column stays lit for only a few microseconds.
Columns on A, rows on B
The circuit centers on a PIC 16F84A. The chip runs at 4 MHz and has two I/O ports (groups of input and output pins). Port A has 5 pins. Port B has 8.
Port A chooses the active column. Each pin connects to one column of the matrix, and only one column turns on at a time. Port B chooses which rows light up in that column. Its 7 data pins map to the 7 rows of LEDs.
The eighth pin of Port B is an input. A push button connects there, but the main program runs without user input.
Current limiting resistors sit between the chip and the LEDs. Without them, the LEDs would draw too much current. They could damage themselves or the chip.
Half a second per letter
The program starts by setting up the hardware. Port A and most of Port B become outputs. The timer gets a prescaler of 64. A prescaler divides the clock, so the timer counts at a slower, more useful speed.
Interrupts drive the timing. An interrupt is a signal that pauses the main program to run a short handler. The Timer0 module counts clock cycles. When it overflows, an interrupt fires and the handler lowers a counter by one. After 50 overflows, about half a second has passed. Then the display moves to the next character.
The main loop does the drawing. It reads the current character index and jumps to that letter’s routine. Each letter routine sends the right row pattern for each of its five columns, one column at a time.
Letters as five numbers
Each letter is a sequence of five column patterns. Take the letter “A”. The first column lights rows 1 through 6 except the middle. The next three columns light the top row and the middle row. The fifth column mirrors the first.
The code writes these patterns straight to Port B as binary values. A zero in a bit means that LED turns on. This is called active low. A one means it stays off. The pattern B'11000000' lights the bottom six LEDs of a column.
A table lookup picks the letter. The character index feeds a computed goto, which jumps to the right letter routine. This avoids a long chain of if then checks.
The clock never waits
The display works only if the scan is fast enough for the eye to blend the columns. Each column shows for a brief moment before the code moves on.
The interrupt runs apart from the display loop. While the main loop cycles through columns, the timer counts in the background. When enough time passes, the interrupt moves the character pointer forward.
This split keeps the display smooth. The column scan never stops to check the clock. The hardware interrupts take care of the timing.
Stars between names
Beyond the alphabet, the code has a star pattern. Four stars appear at the end of each name. They separate one pass from the next before the sequence restarts.
The star is a diamond shape. It is narrow at the top and bottom and wide in the middle. The middle column has all its LEDs lit. The columns next to it have fewer.
Graph paper and guesswork
The timing took experiments. Too fast, and the display looked dim because each LED had less time to shine. Too slow, and the letters flickered.
The binary patterns needed careful planning. I drew each letter on graph paper first. One wrong bit, and the letter looked broken or messed up other characters.
Memory limits forced me to be efficient. The PIC 16F84A has only 1K of program memory and 68 bytes of RAM. Every instruction counts. The letter patterns take a lot of that space, so there was little room for extra features.
Debugging assembly on real hardware is hard. There are no print statements and no debugger. When something broke, I reasoned through the code one instruction at a time. A simulator helped. It could not catch timing problems that only showed up on the real circuit.
Every screen scans
This project showed me how displays work at the hardware level. Every screen scans in some way. Even modern monitors refresh pixel by pixel. The ideas from this small matrix apply everywhere.
Assembly makes you understand the machine. No layer hides what the processor does. Every register and every clock cycle matters. That habit stayed useful when I moved to higher level languages. Knowing what happens underneath helps you write better code at any level.
Interrupts also changed how I think about concurrency, which means two things running at the same time. Here, the main loop and the timer run on their own but share one counter variable. It is the simplest kind of concurrency. It still shows the same patterns that cause race conditions in large systems.
Interested in working together? Check out my services and pricing to see how we can collaborate on your next project. Let's Build