Running Message using 8×8 LED Matrix MAX7219 driver

Overview

Visual cues ,e.g. hand signals,  are a time-tested communication schemes that help humanity survive throughout the history. It provides a simple, quick, yet understandable common ground for communication. Light-emitting Diodes (LEDs) are  typical electronic elements to demonstrate a visual cue, such as indicating a device’s ON or OFF states.

What if we arranged LEDs in a matrix? This is now employed in many displays to demonstrate intricate patterns, patterns that would result in images.

Electronic visual displays, such as an LCD or OLED screens, are important devices to make a project more human-friendly i.e. readable.

This simple project utilizes an 8×8 LED Matrix with a built-in MAX7219 to project a running message “CreateLabz” in the LED Matrix.

Hardware Used

Software Used

Libraries Used

HCMAX7219.h
             This Arduino library is used to work with MAX7219 LED Driver IC which is attached already in the 8×8 Matrix LED module.

             This library also supports an 8-digit 7-segment module (HCMODU0082) and an 8×8 Serial Dot Matrix Display Module (HCOPTO0014).

SPI.h

             This library helps you communicate with the SPI devices using the SPIN pins (pins 10-13). We used pins 10 (LOAD/CS), 11 (DIN/SDI), and 13(SCL/CLK) for this project.

MAX7219 driver

             This serial input/output common-cathode microprocessor display drivers interfaces microprocessors to 7-segment numeric LED displays of up to bar graph displays, series of 7-segment displays, and 8×8 LED matrix displays. Since the driver is already in the module, it is convenient and pin configurations are simplified.

Application Discussion

              The MAX7219 is a multiplexing chip that is commonly paired as a LED Driver to an 8×8 LED Matrix. A library, HCMAX7219, is imported which serves as a pre-coded address writer.

             To install the library, Go to the installation folder of Arduino. In default setup, the folder is usually located at C:/Program Files x86/Arduino/libraries. Extract the content of the zip in the library folder.

 

The Guts of the Matrix LED is what you really expect. LEDs arranged in a matrix. Duh !

Schematics

Code

 


//Retrieved from (https://github.com/HobbyComponents) 
//Running Message example  
#include <HCMAX7219.h>
#include "SPI.h"

/* Set the LOAD (CS) digital pin number*/
#define LOAD 10
/* Create an instance of the library */
HCMAX7219 HCMAX7219(LOAD);

/*     
  PINOUT:
  MODULE.....UNO/NANO.....MEGA
  VCC........+5V..........+5V
  GND........GND..........GND
  DIN........11...........51
  CS (LOAD)..10...........10
  CLK........13...........52
 */

void setup() 
{ 
}

/* Main program */
void loop() 
{
  int Loopcounter, Position;

  /* Clear the output buffer */
  HCMAX7219.Clear();
  
  /* SCROLL SOME TEXT 2 TIMES BEFORE MOVING ON */
  for (Loopcounter = 0; Loopcounter <= 2; Loopcounter++)
  {
    for(Position=0; Position <= 180; Position++)
    {
      HCMAX7219.printMatrix("CreateLabz Academy", Position);
      HCMAX7219.Refresh();
      delay(80);
    }
  }
}

 

Code Description

 

#include HCMAX7219.h 

This line of code imports the HCMAX7219.h library installed in the local Arduino Library folder.

#define LOAD 10

Sets the LOAD (CS) digital pin number

HCMAX7219 HCMAX7219(LOAD);

Create an instance of the library

byte Loopcounter;

int Position;

Initializes the Loopcounter, and the Position of the character.

HCMAX7219.Clear();

Clears the display on the 8×8 Matrix

for (Loopcounter = 0; Loopcounter &lt;= 2; Loopcounter++)
{
  for(Position=0; Position &lt;= 180; Position++)
    {
    HCMAX7219.printMatrix("CreateLabz Academy", Position);
    HCMAX7219.Refresh();
    delay(80);
    }
}

The inner for loop displays on the 8×8 Matrix the string “CreateLabz Academy”. The position, with respect to the 64 horizontal dots on the display, increments every 80ms. For this instance, The pixels of C moves to the left every 80ms.

The HCMAX7219.Refresh() updates the current LEDs on the 8×8 Matrix. This is similar to the refreshing of the monitor, where delay(80) serves as the refresh rate.

The 180 serves as the pixel width of the running message. If the pixel width is greater than the message, there will be no display. If the pixel width is less than the message, the message will be cut short.

Library Description/Functions

The HCMAX7219.cpp and .h library can drive cascaded 7-segments and 8×8 Matrix LEDs. Define in the pre-processor (or the topmost part of the code) the following which suits your need.

#include &lt;HCMAX7219.h&gt; //Imports the HCMAX7219.h 
#define LOAD //Where LOAD is the CS digital Pin Number 
HCMAX7219 HCMAX7219(LOAD); //Initialize HCMAX7219 with LOAD 
#define NUMBEROFDRIVERS NUMBER  //Number indicates cascaded Matrices/Segments 
#define DOTMATRIX //Define if 8x8 serial dot matrix module HCOPTO0014

Function calls in the library

.Intensity(Level, Driver); //Sets the luminosity 
.printMatrix(char textString[], unsigned int Offset); //Prints out textString[]. Can be replaced with str type.
.printMatrix(long number, byte decimalPlace, unsigned int Offset);
.printMatrix(long number, unsigned int Offset); //Prints out the number
.Invert(byte InvertState); //Inverts the display 
.Clear() //Clears the current display 
.Refresh() //Updates the current display

 

Conclusion

             The 8×8 Matrix LED with MAX7129 is a versatile electronic component that can be connected via  OUT->IN pins to drive more than 1 matrix (cascading multiple matrix modules).

 

Reference

https://github.com/HobbyComponents/HCMAX7219

http://forum.hobbycomponents.com/viewtopic.php?f=58&t=1794

https://datasheets.maximintegrated.com/en/ds/MAX7219-MAX7221.pdf

https://www.circuitspecialists.com

The post Running Message using 8×8 LED Matrix MAX7219 driver appeared first on CreateLabz.

8x8 matrix8x8 matrix ledArduinoDisplayKnowledgebaseLed matrixMatrixMatrix ledMax7129Running message

Leave a comment

All comments are moderated before being published