The following blog post is based on this Makersguide.com tutorial: MAX7219 LED Matrix Display Arduino Tutorial (4 Examples) (makerguides.com). These are my notes from reading this post.
Notes:
The code can be used for 8x8, 8x32 and even larger displays. Using the MD_Parola and the MD_MAX72XX Arduino Libraries as these make scrolling text and other animations easy to use.
Connecting the dot matrix display to the Arduino:
Using an SPI interface - Hardware locations on an Arduino Uno
MOSI: 11 or ICSP-4
MISO: 12 or ICSP-1
SCK: 13 or ICSP-3
Level: 5V
Hardware Configuration in Arduino code:
Set the Hardware type
Set number of devices to 4 (check when it arrives)
Arduino example code:
/* Example code for scrolling text effect on MAX7219 LED dot matrix display with Arduino. More info: https://www.makerguides.com */
// Include the required Arduino libraries:
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
// Define hardware type, size, and output pins:
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 4
#define CS_PIN 3
// Create a new instance of the MD_Parola class with hardware SPI connection:
MD_Parola myDisplay = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
// Setup for software SPI:
// #define DATAPIN 2
// #define CLK_PIN 4
// MD_Parola myDisplay = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);
void setup() {
// Intialize the object:
myDisplay.begin();
// Set the intensity (brightness) of the display (0-15):
myDisplay.setIntensity(0);
// Clear the display:
myDisplay.displayClear();
myDisplay.displayText("Scrolling text", PA_CENTER, 100, 0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
}
void loop() {
if (myDisplay.displayAnimate()) {
myDisplay.displayReset();
}
}
Start off by including all required Arduino libraries - MDMAX in this case implements the LED matrix’s hardware functions whilst MD Parola controls the text effects. The SPI library is used for Serial Peripheral Interface communication between display and the arduino.
Specify what hardware is being used using #define
At the end of the setup using the ‘displayText’ function we will pass 5 arguments “pText, align, speed, pause, effectIn, effectOut” the first parameter will be “scrolling text”. Followed by the alignment (centre, left, right), the speed between animation frames, the pausing of the animation and the effectIn and effectOut can be set to PA_Scroll_Left.
Lastly this code uses a Loop which uses an if statement to ‘animate the display using the currently specified text and animation parameters and returns true when the animation has finished’. This gets rest when it is finished.
Text Sprites:
On the tutorial, they also listed some text sprite examples, one example I am considering using is the "Walking man"
const uint8_t F_WALKER = 5;
const uint8_t W_WALKER = 7;
const uint8_t PROGMEM walker[F_WALKER * W_WALKER] = // walking man
{
0x00, 0x48, 0x77, 0x1f, 0x1c, 0x94, 0x68,
0x00, 0x90, 0xee, 0x3e, 0x38, 0x28, 0xd0,
0x00, 0x00, 0xae, 0xfe, 0x38, 0x28, 0x40,
0x00, 0x00, 0x2e, 0xbe, 0xf8, 0x00, 0x00,
0x00, 0x10, 0x6e, 0x3e, 0xb8, 0xe8, 0x00,
};
As my piece is beginning to look like an interactive story telling piece I thought that this would be a nice way to add some character to the LED Matrix story telling.
In terms of my piece I am still waiting on components to arrive to test out the tutorial information. I will follow up shortly when I receive those parts and will begin testing the code I came across today until then I will be exploring the libraries documentation.
Comments