LED матрица 8х32 - MAX7219

Отображение бегущего текста на LED матрице 8х32 MAX7219
  #include <SPI.h>
  #include <Adafruit_GFXx.h>
  #include <Max72xxPanel.h>
  int pinCS = 10;
  int numberOfHorizontalDisplays = 1;
  int numberOfVerticalDisplays = 4;
  Max72xxPanel matrix = Max72xxPanel(pinCS, numberOfHorizontalDisplays, numberOfVerticalDisplays);
  String tape = " ";
  int wait = 30;
  int spacer = 1;
  int width = 5 + spacer;
  int i;
  String utf8rus(String source)
  {
    int i,k;
    String target;
    unsigned char n;
    char m[2] = { '0', '\0' };
    k = source.length(); i = 0;
    while (i < k) {     n = source[i]; i++;
      if (n >= 0xC0) {
        switch (n) {
          case 0xD0: {
            n = source[i]; i++;
            if (n == 0x81) { n = 0xA8; break; }
            if (n >= 0x90 && n <= 0xBF) n = n + 0x2F;
            break;
          }
          case 0xD1: {
            n = source[i]; i++;
            if (n == 0x91) { n = 0xB7; break; }
            if (n >= 0x80 && n <= 0x8F) n = n + 0x6F;
            break;
          }
        }
      }
      m[0] = n; target = target + String(m);
    }
  return target;
  }

int x;
int y;

void setup() {
     matrix.setIntensity(5);
     matrix.setRotation(matrix.getRotation()+1);
}

void loop() {
        tape = utf8rus("ArduBlock RU EN Виталий Петров");
        for ( int i = 0 ; i < width * tape.length() + matrix.width() - 1 - spacer; i++ )
             {
             matrix.fillScreen(LOW);
             int letter = i / width;
            x = (matrix.width() - 1) - i % width;
           y = (matrix.height() - 8) / 2;
            while ( x + width - spacer >= 0 && letter >= 0 ) {
            if ( letter < tape.length() ) {
              matrix.drawChar(x, y, tape[letter], HIGH, LOW,1);
            }
            letter--;
           x -= width;
          }
          matrix.write();
          delay(30);
        }
} 

Открыть пример: Online ArduBlock



Отображение числовых переменных на LED матрице 8х32 MAX7219
  #include <SPI.h>
  #include <Adafruit_GFXx.h>
  #include <Max72xxPanel.h>
  int pinCS = 10;
  int numberOfHorizontalDisplays = 1;
  int numberOfVerticalDisplays = 4;
  Max72xxPanel matrix = Max72xxPanel(pinCS, numberOfHorizontalDisplays, numberOfVerticalDisplays);
  String tape = " ";
  int wait = 30;
  int spacer = 1;
  int width = 5 + spacer;
  int i;
  String utf8rus(String source)
  {
    int i,k;
    String target;
    unsigned char n;
    char m[2] = { '0', '\0' };
    k = source.length(); i = 0;
    while (i < k) {     n = source[i]; i++;
      if (n >= 0xC0) {
        switch (n) {
          case 0xD0: {
            n = source[i]; i++;
            if (n == 0x81) { n = 0xA8; break; }
            if (n >= 0x90 && n <= 0xBF) n = n + 0x2F;
            break;
          }
          case 0xD1: {
            n = source[i]; i++;
            if (n == 0x91) { n = 0xB7; break; }
            if (n >= 0x80 && n <= 0x8F) n = n + 0x6F;
            break;
          }
        }
      }
      m[0] = n; target = target + String(m);
    }
  return target;
  }

int x;
int y;
String text = "A";
int mm = 0;
int ss = 0;

void setup() {
     matrix.setIntensity(5);
     matrix.setRotation(matrix.getRotation()+1);
}

void loop() {
    mm = 12;
    ss = 45;
    text = String(mm) + String(":") + String(ss);
     tape = utf8rus(text);
        x = (matrix.width() - (tape.length() * width)) / 2;
        y = (matrix.height() - 8) / 2;
        matrix.fillScreen(LOW);
        for ( int i = 0 ; i < tape.length(); i++ ) {
           int letter = i;
           matrix.drawChar(x, y, tape[letter], HIGH, LOW, 1);
            x += width;
         }
         matrix.write();
         delay(1000);
} 

Открыть пример: Online ArduBlock



Видеоурок: