Safari browser sometimes has issues displaying images...

I.e: *you have to click on the images to see them...

For a better browsing experience on Brainy-Bits

Please use Chrome, Edge or Firefox browser.

  • Brainy-Bits

Arduino Scrolling Text v2.0 – With direction and speed control!



OVERVIEW


Quite a while ago, I did a tutorial on how to create Scrolling Text using a MAX7219 LED Matrix and an Arduino.


It worked, but the library I used at the time was very limited and hard to modify how the text scrolls across multiple matrix modules.


So I decided to make this new tutorial but this time using a more flexible library which provides more options.


The library in question is the ‘Parola’ library by MajicDesigns.


In this tutorial I will use six MAX7219 LED matrix linked together with a slider potentiometer to control the direction and speed of the scrolling text in real time.

PARTS USED


Arduino UNO

Amazon usa

Amazon canada


MAX7219 Modules

Amazon usa

Amazon canada

Analog Slider

Amazon usa

Amazon canada


These are Amazon affiliate links...

They don't cost you anything and it helps me keep the lights on

if you buy something on Amazon. Thank you!

CONNECTIONS




The MAX7219 modules I’m using, have two sets of five pins, IN and OUT, you connect IN pins of the first module to the Arduino and then connect the OUT pins to the IN pins of another modules.


The MAX7219 matrix modules communicate using the SPI protocol so we need to use specific pins.


Since we are using the Arduino UNO for this tutorial the SPI pins are located at 10 (SS), 11 (MOSI) and 13 (SCK).

These modules by themselves don’t require much current, about 150mA, but we are using six of them in this tutorial, and when all the Led’s are lit up, the current goes up to 900mA, so we need to use an external 5V power supply.


*note: The UNO if powered by USB can supply up to 500mA, if you power it using the DC jack with an external power supply, it can supply up to 1Amp.  Since 900mA is pretty close to the limit, I decided to power the Matrix module with an external 5V 2A power supply separate from the UNO which I powered using a simple USB cable from my computer.


The Slider potentiometer has two sets of 3 pins, (OTA and OTB), both set do the same thing and you can use any one of them.


The connections are as follow:


For the Slider:

5V and GND of the UNO are going to VCC and GND of the OTA set of the Slider.

A0 of the UNO connects to the OTA of the Slider.


For the LED Matrix we are using the IN pins of the right most module:

Pin 10 (SS) of the UNO is connected to right most Matrix CS pin.

Pin 11 (MOSI) is connected to the DIN pin.

and pin 13 (SCK)is connected to the CLK pin.


After that the OUT pins of one Matrix is connected with jumpers to the IN pins of the next module.

LIBRARY CONFIGURATION


The Parola library as a dependency and requires additional library:

MD_MAX72xx Arduino library


This library has support for many different types or models of LED Matrix.


So you need to edit the library file to set the right setting to select the Led Matrix you are using.


For more information on what file to edit in the library have a look at the tutorial video.

THE CODE


To simplify the code, instead of using the Serial Monitor to enter the desired text to be displayed on the Led Matrix, we will enter the message to be displayed inside the code itself.


The slider pot value is used to decide the direction and speed of the scrolling.

When it sits in the middle the text will scroll slowly, if we move it to the right or left, then the text will start scrolling in that direction and the more we slide the speed will be increased.


The Parola library has many many more options you can experiment with, like fading, scrolling up and down, so I invite you to take a more in depth look at all the options available if you want to experiment further.


As always for more information about the tutorial and explanation of the code please watch our tutorial video.

#include <MD_Parola.h>
//   https://github.com/MajicDesigns/MD_Parola
#include <MD_MAX72xx.h>
//   https://github.com/MajicDesigns/MD_MAX72xx
#include <SPI.h>

#define MAX_DEVICES 6  // Number of modules connected
#define CLK_PIN   13   // SPI SCK pin on UNO
#define DATA_PIN  11   // SPI MOSI pin on UNO
#define CS_PIN    10   // connected to pin 10 on UNO

#define slider_pin A0  // OTA or OTB pin on slider
int slider_val;  // used to hold the slider analog value
int slide_scroll_speed;   // used when changing scroll speed

MD_Parola P = MD_Parola(CS_PIN, MAX_DEVICES);  // SPI config

int scrollSpeed;    // used to set text scroll speed in Parola at start

// sets scrolling direction if slider in middle at start
textEffect_t scrollEffect = PA_SCROLL_LEFT;

textPosition_t scrollAlign = PA_LEFT;  // how to aligh the text

int scrollPause = 0; // ms of pause after finished displaying message

#define	BUF_SIZE	75  // Maximum of 75 characters
char curMessage[BUF_SIZE] = { "Brainy-Bits" };  // used to hold current message


void setup()
{

  pinMode(slider_pin, INPUT);
  
  P.begin();  // Start Parola
  
  // configure Parola
  P.displayText(curMessage, scrollAlign, scrollSpeed, scrollPause, scrollEffect, scrollEffect);

}

void loop() {

  slider_val = analogRead(A0);  // check slider analog value
  
  if (slider_val > 600) {  // if slider to the left
    
    scrollEffect = PA_SCROLL_LEFT;  // Change direction to Left
    
    P.setTextEffect(scrollEffect, scrollEffect); // set new direction in Parola (OLD, NEW)
    
    slide_scroll_speed = map(slider_val, 1023, 0, 15, 400); // map slider value to text scroll speed
    
    P.setSpeed(slide_scroll_speed);  // Set new text scroll speed
    
  }
  
  
  if (slider_val < 350) {  // if slider to the right
    
    scrollEffect = PA_SCROLL_RIGHT;
    
    P.setTextEffect(scrollEffect, scrollEffect);  
    
    slide_scroll_speed = map(slider_val, 1023, 0, 400, 15);
    
    P.setSpeed(slide_scroll_speed);
  }
  

  if (slider_val < 600 && slider_val > 350) {  // if slider in middle
    
    slide_scroll_speed = 500;
    
    P.setSpeed(slide_scroll_speed);
  }


  if (P.displayAnimate()) // If finished displaying message
  {
    P.displayReset();  // Reset and display it again
  }
  
}

TUTORIAL VIDEO


DOWNLOAD


Copy the above Sketch code you want to use above in your Arduino IDE software to program your Arduino.


Don’t forget to make the necessary modification in the MD_MAX72xx library file to reflect the type of module you are using.

48 views

All my content is and will always be Free.

If you feel that my Videos / Tutorials are helping, and you would like to contribute...

 You can toss some coins in the Tip Jar via PayPal.

Select amount then click the “Donate” button.

©2020 by Brainy-Bits