Unleashing Creativity: Designing Custom Displays with PIC18F16Q40 and MAX7219 Modules
The Max7219 is a shift and parallel conversion chip, hence it can effectively save I/O port resources. The digital tube module and the dot matrix display module made with this chip are two common functional modules.
For small board cards like the PIC18F16Q40, choosing the Max7219 (Link) module as the display thing is super suitable. .
To use the PIC18F16Q40 (Link) to drive the Max7219 module, the first thing to do is set up the pins with MCC (Microchip Configuration Compiler).
The PIC18F16Q40 microcontroller, which works well with the Max7219, is also available at Unikeyic (Link). Unikeyic provides a wide range of quality components for your electronics projects.
When establishing the following connections, the pin configuration is shown in Figure 1:
DIN —— RC4
CLK —— RC6
CS —— RC7
Where: DIN stands for serial data input, CLK stands for serial clock input, and CS is the chip select pin.

The corresponding pin names are shown , and all three pins are set to output mode.

Additionally, to facilitate programming, the system's delay function was called.

Due to the simulation of serial data transmission using I/O, the function for serial data sending is as follows:

The function for writing data to a register is:

Given that the two modules have different functionalities, their initialization functions and main programs are distinct. Below is a detailed introduction for each.
Driving Serial Digit Display Module The serial digit display module is designed to control an 8-digit 7-segment digit tube using the MAX7219 chip. This chip integrates an internal B-type BCD code encoder with a multiplex scanning circuit and segment drivers. Additionally, it includes an 8x8 static RAM for storing display data, as well as an external register to set the segment current for each LED. Each datum can be individually addressed without rewriting when updated, and it also allows users to choose between encoding or not encoding for each datum. During the display process, there is no flickering or jitter, and the module supports cascading for expanding the number of digits displayed. The appearance of the module is shown in Figure 4:

8-bit Serial Digital Tube Module
The initialization function for this module is:

To achieve the display effect, the main program is as follows:

Compared with conventional digital tube displays, this display method features fewer pin resources required and higher brightness, making it suitable for industrial control applications.

Display performance
2.Driven Matrix Display Module
Driving the Serial Digit Display Module. It uses the MAX7219 chip to control an 8-digit 7-segment digit tube. The chip has a B-type BCD code encoder, multiplex scanning circuit, segment drivers, 8x8 static RAM for data storage, and an external register for LED segment current. Data can be separately addressed and updated without rewrite. Users can choose encoding. It shows without flickering or jitter and can be cascaded. See Figure 4 for its appearance.

Dot Matrix Display Module Pin Layout

Dot Matrix Module Schematic Diagram
The initialization function for the MAX7219 is:

To achieve the display effects, the main program is:

In this context: The inner loop's job is to show a single character. And the outer loop is to go through and display what's in the character library. When showing, after each character is displayed, the state of the LEDs on the board is changed once.
