MAX7219 Display driver internal block diagram.

Raspberry Pi and the 8-Digit LED MAX7219 Display Driver

by Lewis Loflin

The program presented below will allow Raspberry in Python and setup a MAX7219 display driver to act as a four digit counter. The program was ported over from Arduino C to illustrate how coding can be reused.

The MAX7219 display driver can drive 8 digit multiplexed LED display or a 8X8 LED matrix. This is setup in software. It includes selectable internal binary-coded-decimal (BCD) decoding which is used here.

It can also be cut on/off by a single command, the number of digits displayed, and intensity are all selectable in software. See "def initMAX7219()" below.

Refer to the block diagram above. 16-bit data input is broken into 2 8-bit data bytes the first being an address and the second being data. Using the function writeMAX7219(digit, k) digit is the digit value and k is position pointer.

For example assuming BCD mode and digit = 1 and k = 1 a one will be displayed on the far right of the display. writeMAX7219(digit, k) uses ssrOut() twice.

BCD code is limited to 0-9. Here we take a for loop where i counts from 0-999. Each iteration the value of i is sent to j which the MOD function j with 10 returns remainder value of 0-9.

The position and value are output to the display. The j is then divided by 10. This done 4 times to cover all four digits. Then i will increment and the process will begin again.

In the next section we will use the Python time and datetime function to create a LED real time clock.

See Raspberry Pi Python RTC with MAX7219 Display Driver

The code is rpi_count1.txt

Most Popular videos and Webpages

Web site Copyright Lewis Loflin, All rights reserved.
If using this material on another site, please provide a link back to my site.