HCMAX7219 Library update – Now you can create a moving dot matrix display!

blog-lib-dmd-1

We’ve now updated our HCMAX7219 led driver library to support serial dot matrix displays such as our dot matrix module shown in the above image. The library supports multiple drivers connected in series and a built-in alphanumeric font to make displaying text and numbers simple. With the new added commands it is easy to make a scrolling message display!

An additional update includes using the hardware SPI interface for faster updates.

You can download the new V0.2 of the library from our support forum here.

Or from Github here

There are 3 new added commands for led matrix displays. See the example sketch below for an example of how to use them:

HCMAX7219.printMatrix("TEXT STRING", Offset)

Writes a string of text to the output buffer at position starting at Offset. A value of 1 for offset starts the text at column 1 on the display of driver 1, 8 will start the text from column 8 of driver one, 9 will start the text from column 1 of driver 2 etc. Offset numbers beyond the maximum column number can be set to allow for text to be positioned beyond the ends of the display.

HCMAX7219.printMatrix(Value, Offset)

Writes a positive or negative integer to the display. If negative a ‘-‘ sign will be appended to the beginning of the number. See above of description of Offset.

HCMAX7219.printMatrix(Value, Decimal_Position, Offset)

Writes a positive or negative integer to the display. If negative a ‘-‘ sign will be appended to the beginning of the number. Decimal_Position allows the option to specify the position of a decimal point.
See above of description of Offset.

HCMAX7219.Invert(Mode);

Turns inverted text on or off. Mode is of type boolean and can be one of the following pre-defined values:
INVERTOFF
INVERTON

HCOPTO0014 Arduino Diagram

 

 

Example sketch:

/* FILE:    HCMODU0082_Serial_Dot_Matrix_Example
   DATE:    19/03/15
   VERSION: 0.1
  AUTHOR: Andrew Davies
   
REVISIONS:

19/03/15 Created version 0.1

This is an example of how to use the Hobby Components 8x8 serial dot matrix
module (HCOPTO0014). To use this example sketch you will need to download 
and install the HCMAX7921 library available from the software section of our
support forum (forum.hobbycomponents.com) or on github:
(https://github.com/HobbyComponents)

The library assumes you are using one module. If you have more than one module
connected together then you will need to change the following line in the 
libraries HCMAX7219.h header file to the number of drivers you have connected:

#define NUMBEROFDRIVERS 1 <- Change this number

PINOUT:

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

You may copy, alter and reuse this code in any way you like, but please leave
reference to HobbyComponents.com in your comments if you redistribute this code.
This software may not be used directly for the purpose of promoting products that
directly compete with Hobby Components Ltd's own range of products.

THIS SOFTWARE IS PROVIDED "AS IS". HOBBY COMPONENTS MAKES NO WARRANTIES, 
WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED 
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ACCURACY OR
LACK OF NEGLIGENCE. HOBBY COMPONENTS SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE
FOR ANY DAMAGES INCLUDING, BUT NOT LIMITED TO, SPECIAL, INCIDENTAL OR 
CONSEQUENTIAL DAMAGES FOR ANY REASON WHATSOEVER. */

/* Include the HCMAX7219 and SPI library */
#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);


void setup() 
{       
}


/* Main program */
void loop() 
{
  byte Loopcounter;
  int 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 <= 64; Position++)
    {
      HCMAX7219.printMatrix("HELLO!! ", Position);
      HCMAX7219.Refresh();
      delay(80);
    }
  }
  
  
  /* SCROLL SOME INVERTED TEXT 2 TIMES BEFORE MOVING ON */
  HCMAX7219.Invert(INVERTON);
  for (Loopcounter = 0; Loopcounter <= 2; Loopcounter++)
  {
    for(Position=0; Position <= 64; Position++)
    {
      HCMAX7219.Clear();
      HCMAX7219.printMatrix("HELLO!! ", Position);
      HCMAX7219.Refresh();
      delay(80);
    }
  }
  HCMAX7219.Invert(INVERTOFF);
  
  
  
  /* SCROLL AN INTEGER NUMBER */
  for(Position=0; Position <= 80; Position++)
  {
    HCMAX7219.Clear();
    HCMAX7219.printMatrix(-12345678, Position);
    HCMAX7219.Refresh();
    delay(80);
  }
  
  
  
  /* SCROLL AN INTEGER NUMBER WITH DECIMAL PLACE */
  for(Position=0; Position <= 96; Position++)
  {
    HCMAX7219.Clear();
    HCMAX7219.printMatrix(-12345678, 2, Position);
    HCMAX7219.Refresh();
    delay(80);
  }
  
} 

What you’ll need to make a moving message display:

An Arduino such as this one

One or more serial LED matrix modules

Optional:

Interconnecting cables are supplied with the modules. If you require additional cable to connect from your Arduino to the message display see this item.

61 Comments

Add a Comment

Your email address will not be published.