Skip to content

Making a simple advertisement using Arduino

Summer has started and hiding from the heat, a new video tutorial arrives. The project of creating a simple advertisement using the MAX7219 integrated circuit - LED matrix driver, LED matrix module and Arduino. This task can be solved in a simple way by using external libraries for working with the MAX7219 and the LED matrix in a few lines of code. As a result, an attractive text animation is obtained. It is possible to connect several LED matrix modules, the complete impression would be better.

Electrical scheme

Connection diagram of Arduino, integrated circuit MAX7219 and LED matrix

Required components

  • Arduino UNO (or similar microcontroller)
  • LED matrix
  • Integrated circuit MAX7219

Video tutorial

Program - sketch

#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>

#define HARDWARE_TYPE MD_MAX72XX::PAROLA_HW
#define MAX_DEVICES 1

#define CLK_PIN   13
#define DATA_PIN  11
#define CS_PIN    8

MD_Parola myDisplay = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);

void setup() {
  myDisplay.begin();
  myDisplay.setIntensity(0);
  myDisplay.displayClear();
  myDisplay.displayScroll("< NENADSKY.COM >", PA_CENTER, PA_SCROLL_LEFT, 200);
}

void loop() {
  if (myDisplay.displayAnimate()) {
    myDisplay.displayReset();
  }
}

Explanation of how the program (sketch) works

Definition section

First of all, it is necessary to include three libraries in the program, namely "MD_Parola", "MD_MAX72xx" and "SPI", which allow to easily program the operation of the integrated circuit MAX7219 and thus the LED matrix on which the advertising text will be displayed. All libraries are included in the program using the library manager.

The line "#define HARDWARE_TYPE MD_MAX72XX::PAROLA_HW" defines a constant with the name "HARDWARE_TYPE" whose value is the hardware module of the LED matrix, in this case it is the value of MD_MAX72XX::PAROLA_HW. This depends on the module itself, so it is necessary to read the documentation.

The MAX_DEVICES constant contains information about the number of LED matrix modules that will be used in the project. A value of 1 suggests that there is only one modulus of the matrix.

The constants CLK_PIN, DATA_PIN and CS_PIN are constants with the values 13, 11 and 8. They represent the Arduino pins to which the CLK, DATA and CS pins of the MAX7219 IC are connected.

At the end of this section of the program, the variable (object) that will represent the LED matrix module is defined. It has 3 parameters, the first is an already defined constant by which we tell the program what physical module we are working with, the second is the Arduino pin to which the CS (Chip Select) pin of the IK MAX7219 is connected, and the third parameter is the physical number of the LED matrix module used in circuit (also represented by a constant).

Setup section

myDisplay.begin(); - similarly to the LCD display, the "begin" function initializes the connection with the LED matrix module.

myDisplay.setIntensity(0); - adjustment of matrix illumination intensity (possible values are between 0 and 15)

myDisplay.displayClear(); - deleting the contents of the LED matrix

myDisplay.displayScroll("", PA_CENTER, PA_SCROLL_LEFT, 200); - simple setting to start text scrolling animation. The first parameter is the text to display on the matrix; The second parameter is the alignment of the text to be displayed (center alignment); The third parameter is the effect assigned to the text (scrolling) and finally the speed of the scrolling animation (200 milliseconds).

Some of the possible parameters for the second and third arguments of the "displayScroll" function (note - a complete list of animations is not provided):


No
#2 – alignment#3 - animation
1PA_LEFTPA_SCROLL_UP
2PA_CENTERPA_SCROLL_DOWN
3PA_RIGHTPA_SLICE
4/PA_SCROLL_LEFT
5/PA_SCROLL_RIGHT

Loop section

The loop section is the simplest and shortest part in the program. This "if" block allows the animation to run smoothly (the more often it is called, the better the animation). The "displayAnimate" function returns a logical value of "true" at the moment when the animation is executed. If the animation is finished, the "displayReset" function is called, which returns the program to re-execute the text animation.

More detailed description of used libraries!

en_USEnglish
Powered by TranslatePress