Scrolling text with flexible 32×8 RGB LED Matrix

> 3 min read

Needed a way to display scrolling text or messages? This Flexible 32×8 RGB LED Matrix display may suit your needs! With 256 LEDs on it, you can display text, patterns or even animation if you want to. Therefore, in this tutorial, you’ll be learning how to interface this display with an Arduino.

Overview

8x32rgb_led

Basically, this display is made up of 32 x 8 = 256 LEDs & it is powered by a ws2811 driver, which makes it easier to control (or address) all of the 256 RGB LEDs. It uses a single wire control protocol: which means that we only need one wire to transmit the data into the RGB LED matrix display.

There are actually various arduino libraries available that can be used to control this matrix (such as the FastLED library), but in this tutorial, I’ll be using Adafruit Libraries.
adafruit_logo

Parts required

  • Arduino Uno x 1
  • 32×8 RGB LED Matrix x 1
  • Jumper wires x 3

 

Demo

 

Setup

There are 3 main wires connecting the RGB matrix: Red, Green & Yellow. The red one is power line (+5V), green is data line & yellow is ground. Connect the red wire to the 5V pin, green wire to digital pin D3 & the yellow wire to ground using female to male jumper wires.

 

Testing the LEDs

Now that the wires are connected to the board, we will first test out all the LEDs to make sure that they are all working. Before that, download Adafruit’s NeoPixel library here: https://github.com/adafruit/Adafruit_NeoPixel. After installing the library into the Arduino’s library directory, copy the following code & upload it to the Arduino:

#include <Adafruit_NeoPixel.h>
#include <avr/power.h>

#define PIN            3      //Data pin

// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS      256

// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
// example for more information on possible values.
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

int delayval = 500; // delay for half a second

void setup() {
  pixels.begin(); // This initializes the NeoPixel library.
}

void loop() {
  // For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one.

  for(int i=0;i<NUMPIXELS;i++){

    // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
    pixels.setPixelColor(i, pixels.Color(0,150,0)); // Moderately bright green color.

    pixels.show(); // This sends the updated pixel color to the hardware.

    delay(delayval); // Delay for a period of time (in milliseconds).
    pixels.clear();
  }
}

After uploading, you should see the matrix turning on & off one at a time.

 

Scrolling the Text

After the testing is done, we move on to the ultimate part: scrolling text! To do that, we will first have to import some libraries:

Adafruit GFX Library: https://github.com/adafruit/Adafruit-GFX-Library

Adafruit NeoPixel Library: https://github.com/adafruit/Adafruit_NeoMatrix

For now, we would be scrolling test as the text in 7 different colors each round, but you can change it if you want. We would set the order to NEO_MATRIX_ZIGZAG, as the LEDs are connected in a “zigzag” manner. The code is as follows:

#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>

#define PIN 3

// MATRIX DECLARATION:
// Parameter 1 = width of NeoPixel matrix
// Parameter 2 = height of matrix
// Parameter 3 = pin number (most are valid)
// Parameter 4 = matrix layout flags, add together as needed:
//   NEO_MATRIX_TOP, NEO_MATRIX_BOTTOM, NEO_MATRIX_LEFT, NEO_MATRIX_RIGHT:
//     Position of the FIRST LED in the matrix; pick two, e.g.
//     NEO_MATRIX_TOP + NEO_MATRIX_LEFT for the top-left corner.
//   NEO_MATRIX_ROWS, NEO_MATRIX_COLUMNS: LEDs are arranged in horizontal
//     rows or in vertical columns, respectively; pick one or the other.
//   NEO_MATRIX_PROGRESSIVE, NEO_MATRIX_ZIGZAG: all rows/columns proceed
//     in the same order, or alternate lines reverse direction; pick one.
//   See example below for these values in action.
// Parameter 5 = pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)

Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(32, 8, PIN,
  NEO_MATRIX_BOTTOM    + NEO_MATRIX_RIGHT +
  NEO_MATRIX_COLUMNS + NEO_MATRIX_ZIGZAG,
  NEO_GRB            + NEO_KHZ800);

const uint16_t colors[] = {
  matrix.Color(255, 0, 0), matrix.Color(0, 255, 0), matrix.Color(255, 255, 0),matrix.Color(0, 0, 255), matrix.Color(255, 0, 255), matrix.Color(0, 255, 255), matrix.Color(255, 255, 255)};

void setup() {
  matrix.begin();
  matrix.setTextWrap(false);
  matrix.setBrightness(5);
  matrix.setTextColor(colors[0]);
}

int x    = matrix.width();
int pass = 0;

void loop() {
  matrix.fillScreen(0);
  matrix.setCursor(x, 0);
  matrix.print(F("Test"));

  if(--x < -30
  ) {
    x = matrix.width();

    if(++pass >= 8) pass = 0;
    matrix.setTextColor(colors[pass]);
  }
  matrix.show();
  delay(30);
}

And after uploading the code, you should see test scrolling across the matrix!

 

 

 

You may also like...