16x8 LED Dot Matrix With MAX7219 Module
16x8 LED Dot Matrix With MAX7219 Module
16x8 LED Dot Matrix With MAX7219 Module
The objective of this project is: to show off the use of the module "MAX7219 dot matrix
display module MCU control DIY" In order to using it you will need the module that can
be purchased on ebay:
http://www.ebay.com/itm/171048735052?ssPageName=STRK:MEWNX:IT&_trksid=p3
984.m1439.l2649
And you will need the MaxMatrix libraries files (which are 3):
https://docs.google.com/file/d/0B_YlEklLDDS7MDhRdWJKdmZQTnc/edit?usp=sharing
https://docs.google.com/file/d/0B_YlEklLDDS7WE9lQ1F1aFhnYlE/edit?usp=sharing
https://docs.google.com/file/d/0B_YlEklLDDS7djd5T2JDeFVsaVE/edit?usp=sharing
The sketch with
the code can
be found on the link
below:
https://docs.google.com/file/d/0B_YlEklLDDS7WTF0c2hlVzFCZWc/edit?usp=sharing
See in the attached picture the interconnection diagram between Arduino module and
MAX7219 module (it was used only 2 MAX7219 modules in this case):
Arduino pin 13 (alternative: pin 10) connected to the CLK pin of the module MAX7219
Arduino pin 11 (alternative: pin 8) connected to pin DIN module MAX7219
Arduino pin 10 (alternative: 9 pin) connected to pin CS module MAX7219
GND and VCC (+5V). To expand the number of modules, you should just connect Dout
pin of one MAX7219 module with the Din pin of the another MAX7219 module... and
so on. The MAX7219 Dout pin is at the top of the module while Din pin is at the botton
of the module. Remembering that you can connect modules as you want, just
connecting the output of one module with the input of the other and leaving the other
signals in parallel. In the sketch, you should to modify the parameter "maxInUse" for
the amount of modules that you will use.
Sketch:
/*
############################################################################
####
# File Name:
MAX7219_5.ino
# Board:
Arduino UNO
# Programming Language:
Wiring / C /Processing /Fritzing / Arduino IDE
#
# Objective:
Scrolling LED dot Matrix
#
# Operation:
Scrolls a message over a 16x8 LED dot matrix
#
# Author:
Marcelo Moraes
# Date:
July 9th, 2013
# Place:
Sorocaba - SP - Brazil
#
############################################################################
####
This code is a public example.
*/
//******************************************************************************
// visit this web page for further information about MaxMatrix library
// https://code.google.com/p/arudino-maxmatrix-library/
//******************************************************************************
#include <MaxMatrix.h>
#include <avr/pgmspace.h>
PROGMEM prog_uchar CH[] = {
3, 8, B00000000, B00000000, B00000000, B00000000, B00000000, // space
1, 8, B01011111, B00000000, B00000000, B00000000, B00000000, // !
3, 8, B00000011, B00000000, B00000011, B00000000, B00000000, // "
5, 8, B00010100, B00111110, B00010100, B00111110, B00010100, // #
4, 8, B00100100, B01101010, B00101011, B00010010, B00000000, // $
5, 8, B01100011, B00010011, B00001000, B01100100, B01100011, // %
5, 8, B00110110, B01001001, B01010110, B00100000, B01010000, // &
1, 8, B00000011, B00000000, B00000000, B00000000, B00000000, // '
3, 8, B00011100, B00100010, B01000001, B00000000, B00000000, // (
3, 8, B01000001, B00100010, B00011100, B00000000, B00000000, // )
5, 8, B00101000, B00011000, B00001110, B00011000, B00101000, // *
5, 8, B00001000, B00001000, B00111110, B00001000, B00001000, // +
2, 8, B10110000, B01110000, B00000000, B00000000, B00000000, // ,
4, 8, B00001000, B00001000, B00001000, B00001000, B00000000, // 2, 8, B01100000, B01100000, B00000000, B00000000, B00000000, // .
4, 8, B01100000, B00011000, B00000110, B00000001, B00000000, // /
4, 8, B00111110, B01000001, B01000001, B00111110, B00000000, // 0
3, 8, B01000010, B01111111, B01000000, B00000000, B00000000, // 1
4, 8, B01100010, B01010001, B01001001, B01000110, B00000000, // 2
4, 8, B00100010, B01000001, B01001001, B00110110, B00000000, // 3
4, 8, B00011000, B00010100, B00010010, B01111111, B00000000, // 4
4, 8, B00100111, B01000101, B01000101, B00111001, B00000000, // 5
4, 8, B00111110, B01001001, B01001001, B00110000, B00000000, // 6
4, 8, B01100001, B00010001, B00001001, B00000111, B00000000, // 7
4, 8, B00110110, B01001001, B01001001, B00110110, B00000000, // 8
4, 8, B00000110, B01001001, B01001001, B00111110, B00000000, // 9
2, 8, B01010000, B00000000, B00000000, B00000000, B00000000, // :
2, 8, B10000000, B01010000, B00000000, B00000000, B00000000, // ;
3, 8, B00010000, B00101000, B01000100, B00000000, B00000000, // <
3, 8, B00010100, B00010100, B00010100, B00000000, B00000000, // =
void setup(){
m.init(); // module initialize
m.setIntensity(0); // dot matix intensity 0-15
Serial.begin(9600); // serial communication initialize
}
void loop(){
/*
// this is the code if you want to entering a message via serial console
while (Serial.available() > 0){
byte c = Serial.read();
Serial.println(c, DEC);
printCharWithShift(c, 100);
}
delay(100);
m.shiftLeft(false, true);
*/
// print the active sentences
printStringWithShift(string1, 100);
printStringWithShift(string2, 100);
printStringWithShift(string3, 100);
printStringWithShift(string4, 100);
printStringWithShift(string5, 100);
printStringWithShift(string6, 100);
// print sentences just for tests
//printStringWithShift(string7, 100);
//printStringWithShift(string8, 100);
//printStringWithShift(string9, 100);
//printStringWithShift(string10, 100);
//printStringWithShift(string11, 100);
}
void printCharWithShift(char c, int shift_speed){
if (c < 32) return;
c -= 32;
memcpy_P(buffer, CH + 7*c, 7);
m.writeSprite(32, 0, buffer);
m.setColumn(32 + buffer[0], 0);
for (int i=0; i<buffer[0]+1; i++)
{
delay(shift_speed);
m.shiftLeft(false, false);
}
}
void printStringWithShift(char* s, int shift_speed){
while (*s != 0){
printCharWithShift(*s, shift_speed);
s++;
}
}
void printString(char* s)
{
int col = 0;
while (*s != 0)
{
if (*s < 32) continue;
char c = *s - 32;
memcpy_P(buffer, CH + 7*c, 7);
m.writeSprite(col, 0, buffer);
m.setColumn(col + buffer[0], 0);
col += buffer[0] + 1;
s++;
}
}
Usage
Featured, Phase-Deploy
Updated Feb 27, 2013 by [email protected]
Usage
Include library
#include <MaxMatrix.h>
col is the index of column of the LED to be updated, range from 0 to 79.
row is the index of row of the LED to be updated, range from 0 to 7.
value is the new values of LED, encoded as boolean value (HIGH / LOW).
Write a sprite
m.writeSprite(x, y, sprite)
sprite- n: the sprite contents, encoded in column-based unsigned bytes, each array
element represents 1 column of the sprite. If the sprite has n rows (n < 8), only the n
LMS bits of each byte is used.
The code below display the sprite of letter "A" on the LED matrix
// CH_A stores the sprite 'A'
//
// **
// * *
// * *
// * *
// ****
// * *
// * *
byte CH_A[] = {4, 8, B1111110, B0010001, B0010001, B1111110 };
m.writeSprite(0, 0, sprite);
These 4 functions shift the values of matrix in one of the direction, by default the shift-in
row/column is filled with zero (LED off). To rotate the LED values (i.e. the shift-in row/column is
filled with shift-out values), you can set the rotate flag to true.
m.shiftLeft(true);
You can also shift in the value outside the matrix, by first uploading the values in the buffer
(outside the matrix space you used) and calling the shiftLeft function. This is useful for creating
scrolling message and animation. The code below shows how to scroll the letter 'A' into the LED
matrix (assume one MAX7219 is used):
byte CH_A[] = {4, 8, B1111110, B0010001, B0010001, B1111110 };
m.writeSprite(8, 0, sprite); // write sprite OUTSIDE the LED matrix
for (int i=0; i<CH_A[0]; i++)
{
m.shiftLeft(false, false);
delay(100);
}