Raspberry Pi LED Matrix Library – Installation for multiline m x n MAX7219 LED Matrices
If you buy LED Dot Matrices, you should mind that these must be quadratic.
- some square MAX7219 Dot Matrices
- Jumper (mostly contained in the DIY Dot Matrix Packages)
- female to female Jumper Cable
- soldering utensils
I wrote an article (german) about how to solder a MAX7219 Matrix.
To use this LED Dot Matrices you have to install the python spi library. If you already have done this you can skip this step.
If you haven’t it installed yet, i would recommend to follow this instructions: http://www.100randomtasks.com/simple-spi-on-raspberry-pi
Setup of the Matrices
Once you have soldered all LED Matrices you can connect them. For working correctly it is important to connect them like in the picture below. The first module is bottom left (seen from the front side), the next one above it. When one column is finished you set the next module on the right side at the bottom, the next one above it and so on.
Each Matrix has these Pins:
Right: CLK – CS – DIN – GND – VCC
Left: CLK – CS – DOUT – GND – VCC
The DOUT Pin of the previous matrix is connected with DIN of the following. The other Pins are also connected.
The Pins of the first Matrix are connected to the Raspberry Pi as follows:
I created a GitHub repository, you can download it from there (make sure you have installed the github client):
git clone https://github.com/tutRPi/multilineMAX7219.git && cd multilineMAX7219
In this directory are two important files:
multilineMAX7219.py – This is the main file, which contains all functions
multilineMAX7219_fonts.py – This file contains the letters and symbols of the different fonts. If you want to add some fonts, you should edit this file.
It is important to change the
multilineMAX7219.py file (Line 113/114) and set your individual MATRIX_WIDTH and MATRIX_HEIGHT.
To run a demo you can type
and see the different effects.
In my opinion the graphic functions are espacially interesting on multiline displays.
I made an easy site where you can draw images and display them on your LED Matrices:
The site you can find here.
As you see the code for the Raspberry Pi Logo (on 3×3 matrices) is given. I can import it in python:
And now you can draw it with
For more details look into the multilineMAX7219_demo.py file and multilineMAX7219.py where all functions are described.
I made an example video (this is a short version of the demo file):