Now Trending:

Using Black Pill
STM32F4...

Windows 10
Arduino Envir...

Add extra oomph
to your ...

Using the STM32
‘B...

Menu

New
Products

News

Product Guides

Product
Sketches

Projects

Hardware – Beginner

Hardware –
Intermediate

Software – Beginner

Software –
Intermediate

Tutorials

Getting started with Seven Segment Serial
Displays

Anita | March 16, 2015 |
Software - Intermediate | 7
Comments

How to get started with our serial seven segment display module and
make a cool scrolling display.

This 8 Digit Seven Segment Display Module takes advantage of the Maxim
MAX7219 driver IC to allow you to driver its 8 seven segment LED’s using just 3
digital pins. The display removes all the awkward things associated with driving
seven segment displays such as multiplexing, refresh rates, current limiting
etc. Not only that, headers situated at both ends of the module allow you to
daisy-chain multiple modules together to make even longer displays.

What you will need:

One or more of the serial seven segment modules

An Arduino such as this one

Male to female dupont cable to connect the module to your
arduino

And if you are using more than one module, some female to female Dupont cable

To take care of the software side of things we have created a library that
makes controlling these displays as simple as possible.

You can download the library from our support forum here

Or from Github here.

You will need to download and unzip this library to
the Arduino development environments library area, which can be found in the
following locations.

On Windows:
My
Documents\Arduino\libraries\

On Mac:
Documents/Arduino/libraries/
or similarly for Linux.

Connect the module(s) to your Arduino as follows:

You can use any available digital pins on your Arduino, but you’ll need to
change the pin references in our example sketches:

/* Digital pins used for driving the module */
#define DIN 12
#define CLK 11
#define LOAD(CS) 10

Driving more than one display

By default the library assumes you will only be driving one module. If you
plan to drive more than one you’ll need to make a small change to one of the
library files.

In the HCMAX7912 library folder, locate the file called HCMAX7219.h and open it in a text
editor.

Then find this line towards the top of the file:

#define&amp;nbsp;NUMBEROFDRIVERS&amp;nbsp;1

This sets the number of modules you have connected. Just change the number on
the end to match the number you have and then save the file.

Displaying text

HCMAX7219.print7Seg("TEXT STRING", Offset)

The HCMAX7219 library includes a print function that will allow you to
display alphanumeric text and numbers at any position on the modules. If the
text runs over the display area of one module, the library will automatically
run it on to the next connected module. The offset parameter sets where on the
module(s) display you would like the text to start. Here are some examples:

HCMAX7219.print7Seg(“TEXT STRING”, 1) The first digit of the first module

HCMAX7219.print7Seg(“TEXT STRING”, 8)Â The last digit of the first
module

HCMAX7219.print7Seg(“TEXT STRING”, 9)Â The first digit of the second
module

HCMAX7219.print7Seg(“TEXT STRING”,
16)Â The last digit of the second module

You can also display integer numbers with this command:

HCMAX7219.print7Seg(Value, Offset)

Or integer numbers with a decimal point:

HCMAX7219.print7Seg(Value, Decimal_Position, Offset)

Example sketches:

So, with your modules(s) connected, let’s see how we can use this library to
display some text. Cut and paste the code below and download it to your
Arduino:

/* FILE: HCMODU0082_Serial_7_Segment_Module_Example1
DATE: 19/03/15
VERSION: 0.2

REVISIONS:

12/03/15 Created version 0.1
19/03/15 Updated to work with V0.2 of the HCMAX7219 library

This is an example of how to use the Hobby Components serial 8 digit seven 7
segment display module (HCMODU0082). 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 &amp;lt;- 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 &amp;lt;HCMAX7219.h&amp;gt;
#include "SPI.h"

/* Set the LOAD (CS) digital pin number*/
#define LOAD 10

/* Create an instance of the library */
HCMAX7219 HCMAX7219(LOAD);

void setup()
{
HCMAX7219.Init();
}

/* Main program */
void loop()
{
/* Clear the output buffer */
HCMAX7219.Clear();
/* Write some text to the output buffer */
HCMAX7219.print7Seg("HELLO !!",8);
/* Send the output buffer to the display */
HCMAX7219.Refresh();

while(1);

}

/* FILE: HCMODU0082_Serial_7_Segment_Module_Example2
DATE: 19/03/15
VERSION: 0.2

REVISIONS:

12/03/15 Created version 0.1
19/03/15 Updated to work with V0.2 of the HCMAX7219 library

This is an example of how to use the Hobby Components serial 8 digit seven 7
segment display module (HCMODU0082). 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 &amp;lt;- 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 &amp;lt;HCMAX7219.h&amp;gt;
#include "SPI.h"

/* Set the LOAD (CS) digital pin number*/
#define LOAD 10

/* Create an instance of the library */
HCMAX7219 HCMAX7219(LOAD);

void setup()
{
HCMAX7219.Init();Â
}

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

/* SCROLL SOME TEXT 5 TIMES BEFORE MOVING ON */
for (Loopcounter = 0; Loopcounter &amp;lt;= 5; Loopcounter++)
{
/* We are scrolling 30 characters of text across the entire display */
for (Position = 0; Position &amp;lt;= DISPLAYBUFFERSIZE + 30; Position++)
{
/* Write the test to the output buffer at the position we require */
HCMAX7219.print7Seg("HCMAX7219 SCROLLING TEXT DEMO ",Position);
/* Send the output buffer to the display */
HCMAX7219.Refresh();
delay(200);
}
}

/* WE CAN ALSO DISPLAY INTEGER NUMBERS */

/* Clear the output buffer */
HCMAX7219.Clear();
/* Write some text and output it*/
HCMAX7219.print7Seg("INT NUM.",8);
HCMAX7219.Refresh();
delay(2000);

/* display an example of a negative integer number */
HCMAX7219.Clear();
HCMAX7219.print7Seg(-1234567,8);
HCMAX7219.Refresh();
delay(2000);

/* Clear the output buffer */
HCMAX7219.Clear();
/* Write some text and output it*/
HCMAX7219.print7Seg("WITH DP.",8);
HCMAX7219.Refresh();
delay(2000);

/* Show the DP in different places. Notice when the DP is at the
beginning the number is padded with a zero */
HCMAX7219.Clear();
for (Position = 1; Position &amp;lt;= 7; Position++)
{
HCMAX7219.print7Seg(-1234567,Position,8);
HCMAX7219.Refresh();
delay(1000);
}
}

Related Posts

Arduino: Hacking your Arduino to run code on a
timer

No Comments | Mar 11, 2015

Make a full colour moving message display with just an Arduino
pin! – Library for controlling WS2812 RGM LEDS

13 Comments | Mar 28, 2015

HCMAX7219 Library update â€“ Now you can create a moving dot
matrix display!

61 Comments | Mar 25, 2015

Arduino: Library for multiple keypads

No Comments | Jan 13, 2015

About The Author

Anita

7 Comments

Mustafa October 9, 2016
Reply

Hello Andrew;
I could not change the pin
#define DIN 7
#define CLK
6
I wrote them into my skectch but not.
which file I need to make
changes
Thank you

Andrew October
9, 2016 Reply

The library uses the hardware SPI interface. On an Uno/Nano this is
fixed to pins 11 & 13. The only pin you can reconfigure is the load
(cs) pin.

Ralph Hulslander January 1, 2017
Reply

How do you show variables?

Works great for text!!

Andrew January
3, 2017 Reply

You can use integer type variables directly with the print statement:

int Number = 1234;
HCMAX7219.print7Seg(Number,4);
HCMAX7219.Refresh();

RR Norris May 23, 2019
Reply

Daisy chaining will not work with the module as delivered, as it
incorporates a series diode in the +5v line, so every subsequent module
receives a constantly-diminishing suppy voltage. The diode needs to be
shorted out to maintain 5V on each device.

james December 2, 2019
Reply

Per usarlo come cronometro è possibile ?

Andrew December
3, 2019 Reply

Sì, devi solo scrivere lo schizzo

Yes, you just need to write the sketch

Add a Comment
Cancel reply

Your email address will not be
published.

Comment:*

Name:*

Email Address:*

Website:

Save
my name, email, and website in this browser for the next time I
comment.

Categories

Hardware – Beginner

Hardware – Intermediate

New
Products

News

Product Guides

Product
Sketches

Projects

Software – Beginner

Software – Intermediate

Tutorials

Recent Comments

Peter wood
on Arduino:
Demystifying the blink sketch for the absolute beginner

Rich on Arduino: Control
a DC or stepper motor from a potentiometer

Mitchell
on Build your
own 4x4x4 LED Cube

Andrew on Make
Yours A Ghoulish Tech Pumpkin this Halloween… With Arduino!

Carl Day
on Make Yours
A Ghoulish Tech Pumpkin this Halloween… With Arduino!

kevrim on
Build your own
4x4x4 LED Cube

Andrew on Build
your own 4x4x4 LED Cube

Shane on
Build your own
4x4x4 LED Cube

Andrew on Getting
started with Seven Segment Serial Displays

james on
Getting
started with Seven Segment Serial Displays

Archives

March 2020

June 2019

March 2018

January 2018

October 2017

August 2017

May 2017

April 2017

July 2016

February
2016

December
2015

July 2015

June 2015

April 2015

March 2015

February
2015

January
2015

Meta

Register

Log in

Entries
feed

Comments
feed

WordPress.org

© 2020 Hobby Components
Blog.

Copyright Hobby Components Ltd

Privacy
Policy