Matrix Display Interface with MAX7219
The MAX7219 LED driver saves microcontroller pins and processing time. It uses only three IO pins of an Arduino. It is easy to connect multiple displays by connecting DIN and DOUT pins.
Using a single MAX7219 you can drive 64 LEDs while you only need 4 wires to interface it to a microcontroller. In addition you can daisy chain multiple MAX7219 chips for bigger displays.
There are 16 output lines from the MAX7219 driving 64 individual LEDs. LEDs are arranged as an 8×8 set of rows and columns. Each colum is pulsed for a short time while the row bits for that column are driven.
MAX7219 SPI Interface
The MAX7219 has a four wire SPI interface – clock, data, chip select and ground – making it very simple to connect to a microcontroller.
- Data – DIN – Data Input
- Chip select – Load (CSn) – active low Chip select.
- Clock – SCK
- GND – Ground.
- Data out – DOUT – Data Output is used for cascading of multiple MAX7219
Circuit Connections of Matrix Display
In this example we are using two matrix displays to make a Scrolling Display. For cascading of multiple displays connect DOUT of first display to DIN of second display in series. Keep CLK (clock) and Load (CS) pin common (parallel connection).
You can use readily available modules also for making your own scrolling display.
Circuit Connection for using readily Available Display Modules
Note: Here we have used different pins for CS, DATA and LOAD.
Arduino Code for MAX7219 interface with Arduino
Download Library from here maxmatrix
//Arduino Display Interfacing #include <MaxMatrix.h> #include <avr/pgmspace.h> #define maxDisplays 2 // Number of MAX7219's in use. byte Buf7219[7]; // "width,height,data[5]" single character buffer. //Connections for figure 7.1 const int data = 7; // DIN or MOSI const int load = 6; // CS const int clock = 5; // SCK /* Connections for figure 7.2 const int data = 11; // DIN or MOSI const int load = 10; // CS const int clock = 13; // SCK */ MaxMatrix m(data, load, clock, maxDisplays); // Data array is stored in program memory (see memcpy_P for access). // Parameters are width, height, character data... // There is a speed improvement for characters with height 8 bits see lib. PROGMEM const unsigned char CH[] = { 3, 8, B0000000, B0000000, B0000000, B0000000, B0000000, // space 1, 8, B1011111, B0000000, B0000000, B0000000, B0000000, // ! 3, 8, B0000011, B0000000, B0000011, B0000000, B0000000, // " 5, 8, B0010100, B0111110, B0010100, B0111110, B0010100, // # 4, 8, B0100100, B1101010, B0101011, B0010010, B0000000, // $ 5, 8, B1100011, B0010011, B0001000, B1100100, B1100011, // % 5, 8, B0110110, B1001001, B1010110, B0100000, B1010000, // & 1, 8, B0000011, B0000000, B0000000, B0000000, B0000000, // ' 3, 8, B0011100, B0100010, B1000001, B0000000, B0000000, // ( 3, 8, B1000001, B0100010, B0011100, B0000000, B0000000, // ) 5, 8, B0101000, B0011000, B0001110, B0011000, B0101000, // * 5, 8, B0001000, B0001000, B0111110, B0001000, B0001000, // + 2, 8, B10110000, B1110000, B0000000, B0000000, B0000000, // , 4, 8, B0001000, B0001000, B0001000, B0001000, B0000000, // - 2, 8, B1100000, B1100000, B0000000, B0000000, B0000000, // . 4, 8, B1100000, B0011000, B0000110, B0000001, B0000000, // / 4, 8, B0111110, B1000001, B1000001, B0111110, B0000000, // 0 3, 8, B1000010, B1111111, B1000000, B0000000, B0000000, // 1 4, 8, B1100010, B1010001, B1001001, B1000110, B0000000, // 2 4, 8, B0100010, B1000001, B1001001, B0110110, B0000000, // 3 4, 8, B0011000, B0010100, B0010010, B1111111, B0000000, // 4 4, 8, B0100111, B1000101, B1000101, B0111001, B0000000, // 5 4, 8, B0111110, B1001001, B1001001, B0110000, B0000000, // 6 4, 8, B1100001, B0010001, B0001001, B0000111, B0000000, // 7 4, 8, B0110110, B1001001, B1001001, B0110110, B0000000, // 8 4, 8, B0000110, B1001001, B1001001, B0111110, B0000000, // 9 2, 8, B01010000, B0000000, B0000000, B0000000, B0000000, // : 2, 8, B10000000, B01010000, B0000000, B0000000, B0000000, // ; 3, 8, B0010000, B0101000, B1000100, B0000000, B0000000, // < 3, 8, B0010100, B0010100, B0010100, B0000000, B0000000, // = 3, 8, B1000100, B0101000, B0010000, B0000000, B0000000, // > 4, 8, B0000010, B1011001, B0001001, B0000110, B0000000, // ? 5, 8, B0111110, B1001001, B1010101, B1011101, B0001110, // @ 4, 8, B1111110, B0010001, B0010001, B1111110, B0000000, // A 4, 8, B1111111, B1001001, B1001001, B0110110, B0000000, // B 4, 8, B0111110, B1000001, B1000001, B0100010, B0000000, // C 4, 8, B1111111, B1000001, B1000001, B0111110, B0000000, // D 4, 8, B1111111, B1001001, B1001001, B1000001, B0000000, // E 4, 8, B1111111, B0001001, B0001001, B0000001, B0000000, // F 4, 8, B0111110, B1000001, B1001001, B1111010, B0000000, // G 4, 8, B1111111, B0001000, B0001000, B1111111, B0000000, // H 3, 8, B1000001, B1111111, B1000001, B0000000, B0000000, // I 4, 8, B0110000, B1000000, B1000001, B0111111, B0000000, // J 4, 8, B1111111, B0001000, B0010100, B1100011, B0000000, // K 4, 8, B1111111, B1000000, B1000000, B1000000, B0000000, // L 5, 8, B1111111, B0000010, B0001100, B0000010, B1111111, // M 5, 8, B1111111, B0000100, B0001000, B0010000, B1111111, // N 4, 8, B0111110, B1000001, B1000001, B0111110, B0000000, // O 4, 8, B1111111, B0001001, B0001001, B0000110, B0000000, // P 4, 8, B0111110, B1000001, B1000001, B10111110, B0000000, // Q 4, 8, B1111111, B0001001, B0001001, B1110110, B0000000, // R 4, 8, B1000110, B1001001, B1001001, B0110010, B0000000, // S 5, 8, B0000001, B0000001, B1111111, B0000001, B0000001, // T 4, 8, B0111111, B1000000, B1000000, B0111111, B0000000, // U 5, 8, B0001111, B0110000, B1000000, B0110000, B0001111, // V 5, 8, B0111111, B1000000, B0111000, B1000000, B0111111, // W 5, 8, B1100011, B0010100, B0001000, B0010100, B1100011, // X 5, 8, B0000111, B0001000, B1110000, B0001000, B0000111, // Y 4, 8, B1100001, B1010001, B1001001, B1000111, B0000000, // Z 2, 8, B1111111, B1000001, B0000000, B0000000, B0000000, // [ 4, 8, B0000001, B0000110, B0011000, B1100000, B0000000, // backslash 2, 8, B1000001, B1111111, B0000000, B0000000, B0000000, // ] 3, 8, B0000010, B0000001, B0000010, B0000000, B0000000, // hat 4, 8, B1000000, B1000000, B1000000, B1000000, B0000000, // _ 2, 8, B0000001, B0000010, B0000000, B0000000, B0000000, // ` 4, 8, B0100000, B1010100, B1010100, B1111000, B0000000, // a 4, 8, B1111111, B1000100, B1000100, B0111000, B0000000, // b 4, 8, B0111000, B1000100, B1000100, B0000000, B0000000, // c // JFM MOD. 4, 8, B0111000, B1000100, B1000100, B1111111, B0000000, // d 4, 8, B0111000, B1010100, B1010100, B0011000, B0000000, // e 3, 8, B0000100, B1111110, B0000101, B0000000, B0000000, // f 4, 8, B10011000, B10100100, B10100100, B01111000, B0000000, // g 4, 8, B1111111, B0000100, B0000100, B1111000, B0000000, // h 3, 8, B1000100, B1111101, B1000000, B0000000, B0000000, // i 4, 8, B1000000, B10000000, B10000100, B1111101, B0000000, // j 4, 8, B1111111, B0010000, B0101000, B1000100, B0000000, // k 3, 8, B1000001, B1111111, B1000000, B0000000, B0000000, // l 5, 8, B1111100, B0000100, B1111100, B0000100, B1111000, // m 4, 8, B1111100, B0000100, B0000100, B1111000, B0000000, // n 4, 8, B0111000, B1000100, B1000100, B0111000, B0000000, // o 4, 8, B11111100, B0100100, B0100100, B0011000, B0000000, // p 4, 8, B0011000, B0100100, B0100100, B11111100, B0000000, // q 4, 8, B1111100, B0001000, B0000100, B0000100, B0000000, // r 4, 8, B1001000, B1010100, B1010100, B0100100, B0000000, // s 3, 8, B0000100, B0111111, B1000100, B0000000, B0000000, // t 4, 8, B0111100, B1000000, B1000000, B1111100, B0000000, // u 5, 8, B0011100, B0100000, B1000000, B0100000, B0011100, // v 5, 8, B0111100, B1000000, B0111100, B1000000, B0111100, // w 5, 8, B1000100, B0101000, B0010000, B0101000, B1000100, // x 4, 8, B10011100, B10100000, B10100000, B1111100, B0000000, // y 3, 8, B1100100, B1010100, B1001100, B0000000, B0000000, // z 3, 8, B0001000, B0110110, B1000001, B0000000, B0000000, // { 1, 8, B1111111, B0000000, B0000000, B0000000, B0000000, // | 3, 8, B1000001, B0110110, B0001000, B0000000, B0000000, // } 4, 8, B0001000, B0000100, B0001000, B0000100, B0000000, // ~ }; void setup() { m.init(); m.setIntensity(3); } // Scrolling Text char string[] = "www.circuits4you.com You have successfuly interfaced display"; void loop() { delay(100); m.shiftLeft(false, true); printStringWithShift(string,100); } void printCharWithShift(char c, int shift_speed) { if (c < 32) return; c -= 32; memcpy_P(Buf7219, CH + 7*c, 7); m.writeSprite(maxDisplays*8, 0, Buf7219); m.setColumn(maxDisplays*8 + Buf7219[0], 0); for (int i=0; i<=Buf7219[0]; i++) { delay(shift_speed); m.shiftLeft(false, false); } } void printStringWithShift(char* s, int shift_speed) { while (*s != 0) { printCharWithShift(*s, shift_speed); s++; } }
The above code displays scrolling text on the display.
hi
what would it display?
how to display an array of dots to make some graphic pattern?
can i use it for POV display?
best regards
C:\Users\proteus\Desktop\1\Arduino.lnk\Arduino.lnk.ino:2:23: fatal error: MaxMatrix.h: No such file or directory
#include
i am getting this error what i need to do for resoving this issue
add library, Arduino.lnk.ino looks like you have created desktop shortcut